コード例 #1
0
ファイル: ComparationManager.java プロジェクト: nnydjesus/unq
  public ComparatorObject compareTo(Object obj1, Object obj2) {
    ComparatorObject comparatorObject = new ComparatorObject(obj1, obj2);
    ComparataroFieldPredicate comparataroFieldPredicate = new ComparataroFieldPredicate();

    List<Field> fieldsObject1 =
        ReflectionUtils.getAllFieldToPredicate(obj1, comparataroFieldPredicate);
    List<Field> fieldsObject2 =
        ReflectionUtils.getAllFieldToPredicate(obj2, comparataroFieldPredicate);

    List<Field> commonsFields = ListUtils.intersection(fieldsObject1, fieldsObject2);
    processCommonsField(commonsFields, obj1, obj2, comparatorObject);

    List<Field> differentFieldsObj1 = ListUtils.subtract(fieldsObject1, fieldsObject2);
    List<Field> differentFieldsObj2 = ListUtils.subtract(fieldsObject2, fieldsObject1);

    comparatorObject.addAllFieldsObj1(getFieldsToObject(differentFieldsObj1, obj1));
    comparatorObject.addAllFieldsObj2(getFieldsToObject(differentFieldsObj2, obj2));
    return comparatorObject;
  }