Java Code Examples for java.lang.reflect.Field.equals()

The following are Jave code examples for showing how to use equals() of the java.lang.reflect.Field class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: minlia-iot   File: XmlSignatureAnnotationHelper.java   View Source Code Vote up 6 votes
/**
 * 处理单个实体
 *
 * @param entity 实体对象
 * @param list SinpleField的列表
 * @param signField 签名字段
 */
private static void dealSinpleEntity(Object entity, List<FieldPaired> list, Field signField,
    SignatureAlgorithmic algorithmic, String saltParameterPrefix, String charset) {
  Field[] fields = ArrayUtils.addAll(entity.getClass().getSuperclass().getDeclaredFields(),
      entity.getClass().getDeclaredFields());
  for (Field field : fields) {
    if (field.equals(signField)) {
      continue;
    }
    field.setAccessible(true);
    try {
      if (field.isAnnotationPresent(XmlElement.class)) {
        Object value = field.get(entity);
        if (value == null) {
          continue;
        }
        list.add(new FieldPaired(field.getAnnotation(XmlElement.class).name(), value));
      } else if (field.isAnnotationPresent(ApiRequestEntity.class)) {
        Object nextEntity = field.get(entity);
        dealSinpleEntity(nextEntity, list, signField, algorithmic, saltParameterPrefix, charset);
      }
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
  }
}
 
Example 2
Project: solo-spring   File: Reflections.java   View Source Code Vote up 5 votes
public static boolean matchInheritance(final Field subclassField, final Field superclassField) {
	if (Modifier.isStatic(superclassField.getModifiers()) || subclassField.equals(superclassField)) {
		return false;
	}

	final Package subclassPackage = superclassField.getDeclaringClass().getPackage();
	final Package superclassPackage = superclassField.getDeclaringClass().getPackage();
	final int superFieldModifiers = superclassField.getModifiers();

	return isAccessable(subclassPackage, superclassPackage, superFieldModifiers);
}
 
Example 3
Project: tasfe-framework   File: GeneralMapperReflectUtil.java   View Source Code Vote up 5 votes
/**
 * 获取pojo除主键外的所有字段名
 * <p>
 * 列名为下划线风格
 * </p>
 *
 * @param clazz pojo类-class对象
 * @return columnNames
 */
public static List<String> getAllColumnsExceptPrimaryKey(Class<?> clazz) {
    List<String> columns = new ArrayList<String>();
    Field primaryField = getPrimaryFieldNotCareNull(clazz);
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        if (primaryField != null && !field.equals(primaryField)) {
            columns.add(StringUtil.camelToUnderline(field.getName()));
        }
    }
    return columns;
}
 
Example 4
Project: jrpip   File: ClassTypeHelper.java   View Source Code Vote up 5 votes
public int compare(Field o1, Field o2)
{
    if (o1.equals(o2))
    {
        return 0;
    }

    return ClassTypeHelper.isPrintableClass(o1.getType()) ? -1 : 1;
}
 
Example 5
Project: WiFiProbeAnalysis   File: BaseHbaseDao.java   View Source Code Vote up 4 votes
public BaseHbaseDao(Class<?> type) throws NoSuchFieldException, SecurityException{
	this.type = type;
	HbaseTable table = type.getAnnotation(HbaseTable.class);
	tableName = table.name();
	rowKeyField = type.getDeclaredField(table.rowKey());
	//初始化
	couple_field_mapping = new HashMap<HbaseColCouple,Field>();
	fieldName_couple_mapping = new HashMap<String,HbaseColCouple>();
	fieldName_field_mapping = new HashMap<String,Field>();
	positiveField = new ArrayList<Field>();
	lazy_fieldName_field_mapping = new HashMap<String,Field>();
	
	Field[] fields = type.getDeclaredFields();
	for(Field field:fields){
		//maping条件
		//1:不是主键
		if(!field.equals(rowKeyField)){
			//2.1:有HbaseColumn注释
			HbaseColumn annotation = field.getAnnotation(HbaseColumn.class);
			if(annotation!=null){
				HbaseColCouple col = new HbaseColCouple(annotation.family(),
						annotation.qualifier());
				couple_field_mapping.put(col, field);
				fieldName_couple_mapping.put(field.getName(), col);
				fieldName_field_mapping.put(field.getName(), field);
			}
			//2.2:有HbaseOneToMany注释
			HbaseOneToMany oneToMany = field.getAnnotation(HbaseOneToMany.class);
			if(oneToMany!=null){
				if(oneToMany.lazy()){	//不主动加载
					lazy_fieldName_field_mapping.put(field.getName(),field);
				}else{	//主动加载
					fieldName_field_mapping.put(field.getName(),field);
					positiveField.add(field);
				}
			}
			//2.3:有HbaseOneToOne注释
			HbaseOneToOne oneToOne = field.getAnnotation(HbaseOneToOne.class);
			if(oneToOne!=null){
				if(oneToOne.lazy()){	//不主动加载
					lazy_fieldName_field_mapping.put(field.getName(),field);
				}else{	//主动加载
					fieldName_field_mapping.put(field.getName(),field);
					positiveField.add(field);
				}
			}
		}
	}
}