public static Optional < Field > getAnnotatedField ( Class annotation , Class clazz ) { List < Field > fields = getAnnotatedFields ( annotation , clazz ) ; return Optional . ofNullable ( fields . size ( ) > 0 ? fields . get ( 0 ) : null ) ; }
Method getAnnotatedField gets the first annotated field of the type of annotation specified .