Example usage for java.lang.reflect Field equals

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

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this Field against the specified object.

Usage

From source file:adalid.core.AbstractEntity.java

void setSegmentField() {
    Field field = getAnnotations().get(SegmentProperty.class);
    if (field != null) {
        Class<?> type = getDataType();
        String fieldName = field.getName();
        if (field.equals(getSegmentField(fieldName, type))) {
            _segmentFieldName = fieldName;
            _segmentField = field;//from   www  .ja  va 2s.co  m
        }
    }
}

From source file:adalid.core.AbstractEntity.java

void setInactiveIndicatorField() {
    Field field = getAnnotations().get(InactiveIndicator.class);
    if (field != null) {
        Class<?> type = getDataType();
        String fieldName = field.getName();
        if (field.equals(getInactiveIndicatorField(fieldName, type))) {
            _inactiveIndicatorFieldName = fieldName;
            _inactiveIndicatorField = field;
        }//from   w ww  . j a v  a 2 s . c o  m
    }
}

From source file:adalid.core.AbstractEntity.java

void setDescriptionField() {
    Field field = getAnnotations().get(DescriptionProperty.class);
    if (field != null) {
        Class<?> type = getDataType();
        String fieldName = field.getName();
        if (field.equals(getDescriptionField(fieldName, type))) {
            _descriptionFieldName = fieldName;
            _descriptionField = field;//  w  ww .  j  ava 2  s  . c  o m
        }
    }
}

From source file:adalid.core.AbstractEntity.java

void setKeyField(Field field) {
    Class<?> type = getDataType();
    Class<?> fieldType = field.getType();
    String fieldName = field.getName();
    if (field.isAnnotationPresent(UniqueKey.class)) {
        if (field.equals(getUniqueKeyField(fieldName, type))) {
            if (IntegerProperty.class.isAssignableFrom(fieldType) && _numericKeyField == null) {
                _numericKeyFieldName = fieldName;
                _numericKeyField = field;
            }//from   w w  w.  j  a v a  2s  . co m
            if (StringProperty.class.isAssignableFrom(fieldType) && _characterKeyField == null) {
                _characterKeyFieldName = fieldName;
                _characterKeyField = field;
            }
        }
    }
}

From source file:adalid.core.AbstractEntity.java

void setPrimaryKeyField() {
    Field field = getAnnotations().get(PrimaryKey.class);
    if (field != null) {
        Class<?> type = getDataType();
        Class<?> fieldType = field.getType();
        String fieldName = field.getName();
        if (field.equals(getPrimaryKeyField(fieldName, type))) {
            _primaryKeyFieldName = fieldName;
            _primaryKeyField = field;//w  w  w  .ja v a 2 s. c om
            if (IntegerProperty.class.isAssignableFrom(fieldType) && _numericKeyField == null) {
                _numericKeyFieldName = fieldName;
                _numericKeyField = field;
            }
        }
    }
}

From source file:adalid.core.AbstractEntity.java

void setBusinessKeyField() {
    Field field = getAnnotations().get(BusinessKey.class);
    if (field != null) {
        Class<?> type = getDataType();
        Class<?> fieldType = field.getType();
        String fieldName = field.getName();
        if (field.equals(getBusinessKeyField(fieldName, type))) {
            _businessKeyFieldName = fieldName;
            _businessKeyField = field;//from   w  w  w  .j a va  2  s  . c  om
            if (IntegerProperty.class.isAssignableFrom(fieldType)) {
                _numericKeyFieldName = fieldName;
                _numericKeyField = field;
            }
            if (StringProperty.class.isAssignableFrom(fieldType)) {
                _characterKeyFieldName = fieldName;
                _characterKeyField = field;
            }
        }
    }
}

From source file:org.broadinstitute.gatk.utils.commandline.ParsingEngine.java

/**
 * Gets a collection of the container instances of the given type stored within the given target.
 * @param source Argument source./*from  ww  w. j  a v  a 2  s .c  om*/
 * @param instance Container.
 * @return A collection of containers matching the given argument source.
 */
private Collection<Object> findTargets(ArgumentSource source, Object instance) {
    LinkedHashSet<Object> targets = new LinkedHashSet<Object>();
    for (Class clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
        for (Field field : clazz.getDeclaredFields()) {
            if (field.equals(source.field)) {
                targets.add(instance);
            } else if (field.isAnnotationPresent(ArgumentCollection.class)) {
                targets.addAll(findTargets(source, JVMUtils.getFieldValue(field, instance)));
            }
        }
    }
    return targets;
}

From source file:org.jgentleframework.core.intercept.support.StaticMatcher.java

/**
 * Static method field matching.//from w w  w  . j a v  a 2 s  .co m
 * 
 * @param identification
 *            the identification
 * @param clazz
 *            the clazz
 * @param matching
 *            the matching
 * @return true, if successful
 */
@SuppressWarnings("unchecked")
public static boolean staticMethodFieldMatching(Identification<?> identification, Class<?> clazz,
        Matching matching) {

    boolean result = false;
    if (!ReflectUtils.isCast(clazz, identification)) {
        throw new MatchingException("The identification can not be cast to [" + clazz + "]");
    }
    Definition def = (Definition) matching.getMetadata(MetadataKey.DEFINITION).getValue();
    /*
     * X l kim tra identification trn method identification
     */
    if (MethodIdentification.class == clazz) {
        MethodIdentification mi = (MethodIdentification) identification;
        if (mi.getDeclaringClass() == null)
            mi.setDeclaringClass(def.getOwnerClass());
        for (Method method : mi.getMember()) {
            if (ReflectUtils.isCast(MethodConstructorMatching.class, matching)) {
                if (method.equals(((MethodConstructorMatching) matching).getElement())) {
                    result = true;
                    break;
                }
            } else if (ReflectUtils.isCast(ClassMatching.class, matching)) {
                if (method.equals(matching.getMetadata(MetadataKey.METHOD).getValue())) {
                    result = true;
                    break;
                }
            } else {
                if (log.isErrorEnabled())
                    log.error("The 'matching' can not be cast to [" + MethodConstructorMatching.class + "]",
                            new MatchingException());
            }
        }
    }
    /*
     * X l kim tra identification trn field identification
     */
    else if (FieldIdentification.class == clazz) {
        FieldIdentification mi = (FieldIdentification) identification;
        if (mi.getDeclaringClass() == null)
            mi.setDeclaringClass(def.getOwnerClass());
        for (Field field : mi.getMember()) {
            if (ReflectUtils.isCast(FieldMatching.class, matching)) {
                if (field.equals(((FieldMatching) matching).getField())) {
                    result = true;
                    break;
                }
            } else if (ReflectUtils.isCast(ClassMatching.class, matching)) {
                if (field.equals(matching.getMetadata(MetadataKey.FIELD).getValue())) {
                    result = true;
                    break;
                }
            } else {
                if (log.isErrorEnabled())
                    log.error("The 'matching' can not be cast to [" + FieldMatching.class + "]",
                            new MatchingException());
            }
        }
    }
    return result;
}