Example usage for java.lang.reflect Field name

List of usage examples for java.lang.reflect Field name

Introduction

In this page you can find the example usage for java.lang.reflect Field name.

Prototype

String name

To view the source code for java.lang.reflect Field name.

Click Source Link

Usage

From source file:jef.database.DbUtils.java

/**
 * ?update'' <br>/*from w  w w. ja v  a 2s. c  o  m*/
 * ??updateMap
 * 
 * @param <T>
 * @param prepareObj
 */
public static <T extends IQueryableEntity> void fillUpdateMap(T... obj) {
    if (obj == null || obj.length == 0)
        return;
    ITableMetadata m = MetaHolder.getMeta(obj[0]);
    for (T o : obj) {
        BeanWrapper bean = BeanWrapper.wrap(o);
        for (ColumnMapping mType : m.getColumns()) {
            if (mType.isPk()) {
                continue;
            }
            Field field = mType.field();
            o.prepareUpdate(field, bean.getPropertyValue(field.name()), true);
        }
    }
}

From source file:jef.database.DbUtils.java

/**
 * ??Example?/*  w ww  . j  a  v  a  2s.c o  m*/
 * 
 * @param obj
 * @return
 */
@SuppressWarnings("unchecked")
public static <T extends IQueryableEntity> Query<T> populateExampleConditions(T obj, String... properties) {
    Query<T> query = (Query<T>) obj.getQuery();
    ITableMetadata meta = query.getMeta();
    BeanWrapper bw = BeanWrapper.wrap(obj, BeanWrapper.FAST);
    if (properties.length == 0) {
        for (ColumnMapping mType : meta.getColumns()) {
            Field field = mType.field();
            if (obj.isUsed(field)) {
                Object value = bw.getPropertyValue(field.name());
                query.addCondition(field, value);
            }
        }
    } else {
        for (String s : properties) {
            Field field = meta.getField(s);
            if (field == null) {
                throw new IllegalArgumentException("field [" + s + "] not found in object " + meta.getName());
            }
            Object value = bw.getPropertyValue(field.name());
            query.addCondition(field, value);
        }
    }
    return query;
}

From source file:org.projectforge.core.BaseDao.java

private String getSearchName(final String fieldName, final org.hibernate.search.annotations.Field annotation) {
    if (StringUtils.isNotEmpty(annotation.name()) == true) {
        // Name of field is changed for hibernate-search via annotation:
        return annotation.name();
    } else {//from  ww w. jav  a2s.c o  m
        return fieldName;
    }
}

From source file:org.tinygroup.validate.impl.AnnotationValidatorManagerImpl.java

public <T> void addValidatorAnnotation(Class<T> clazz, Field field, Annotation annotation) {

    // Field/*from   w  w  w . j  a  va 2 s  .  c  om*/
    if (isFieldAnnotation(annotation)) {
        return;
    }

    LOGGER.logMessage(LogLevel.DEBUG, "??:[{0}],??:[{1}],:[{2}]",
            clazz.getName(), field.getName(), annotation.annotationType().getName());
    if (hasFiledAnnotationList.contains(field)) {
        FieldValidatorMap map = getFieldValidatorMap(clazz);
        if (map == null) {
            map = new FieldValidatorMap();
        }
        try {
            String wrapperKey = getWrapperKey(clazz, field);
            FieldWrapper fieldWrapper = fieldWrapperMap.get(wrapperKey);
            if (fieldWrapper == null) {
                org.tinygroup.validate.annotation.Field fieldAnnotation = field
                        .getAnnotation(org.tinygroup.validate.annotation.Field.class);
                String name = fieldAnnotation.name();
                if (name == null || "".equals(name)) {
                    name = field.getName();
                }
                fieldWrapper = new FieldWrapper(field, name, fieldAnnotation.title());
                fieldWrapperMap.put(wrapperKey, fieldWrapper);
            }
            map.addValidator(fieldWrapper, "", getValidatorFromAnnotation(field, annotation));
        } catch (Exception e) {
            LOGGER.errorMessage(e.getMessage(), e);
        }
        putClassFieldValidators(clazz, map);

    }

}