/** * Find the getter field on a class which has the given annotation * @param elementClass any class * @param annotationClass the annotation type which is expected to be on the field * @return the name of the field or null if no fields are found with the indicated annotation * @throws IllegalArgumentException if the annotation class is null */ public String getFieldNameWithAnnotation(Class<?> elementClass, Class<? extends Annotation> annotationClass) { String fieldName; if (annotationClass == null) { throw new IllegalArgumentException("the annotationClass must not be null"); } ClassFields<?> cf = getFieldUtils().analyzeClass(elementClass); fieldName = cf.getFieldNameByAnnotation(annotationClass); return fieldName; }
/** * Find the getter field on a class which has the given annotation * @param elementClass any class * @param annotationClass the annotation type which is expected to be on the field * @return the name of the field or null if no fields are found with the indicated annotation * @throws IllegalArgumentException if the annotation class is null */ public String getFieldNameWithAnnotation(Class<?> elementClass, Class<? extends Annotation> annotationClass) { String fieldName; if (annotationClass == null) { throw new IllegalArgumentException("the annotationClass must not be null"); } ClassFields<?> cf = getFieldUtils().analyzeClass(elementClass); fieldName = cf.getFieldNameByAnnotation(annotationClass); return fieldName; }