Example usage for org.apache.commons.lang.reflect FieldUtils getField

List of usage examples for org.apache.commons.lang.reflect FieldUtils getField

Introduction

In this page you can find the example usage for org.apache.commons.lang.reflect FieldUtils getField.

Prototype

public static Field getField(Class cls, String fieldName) 

Source Link

Document

Gets an accessible Field by name respecting scope.

Usage

From source file:org.brushingbits.jnap.persistence.hsearch.FullTextDao.java

protected String[] getIndexedFields() {
    if (this.indexedFields == null) {
        PropertyDescriptor[] beanProperties = BeanUtils.getPropertyDescriptors(getEntityClass());
        List<String> fields = new ArrayList<String>();
        for (PropertyDescriptor propertyDescriptor : beanProperties) {
            Field field = ReflectionUtils.getAnnotation(Field.class, propertyDescriptor.getReadMethod());
            if (field == null) {
                java.lang.reflect.Field propertyField = FieldUtils.getField(getEntityClass(),
                        propertyDescriptor.getName());
                if (propertyField != null && propertyField.isAnnotationPresent(Field.class)) {
                    field = propertyField.getAnnotation(Field.class);
                }/*from w  ww. j a v  a 2s .com*/
            }
            if (field != null) {
                String fieldName = propertyDescriptor.getName();
                if (StringUtils.isNotBlank(fieldName)) {
                    fieldName = field.name();
                }
                fields.add(fieldName);
            }
        }
    }
    return this.indexedFields;
}