Skip to content

Commit

Permalink
支持不同类型对象的比对;比包含父类字段;
Browse files Browse the repository at this point in the history
  • Loading branch information
dadiyang committed Jun 6, 2020
1 parent edc1547 commit 727e167
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ boolean isSimpleField(Object first, Object second) {
return clazz.isPrimitive() || WRAPPER.contains(clazz);
}

Set<String> getAllFields(Set<String> firstFields, Set<String> secondFields) {
/**
* 根据配置的规则决定取两个对象字段的交集或并集
*/
Set<String> getAllFieldNames(Set<String> firstFields, Set<String> secondFields) {
Set<String> allFields;
// 只取交集
if (isBothExistFieldOnly()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<FieldInfo> getDiffFields(Object first, Object second) {
} else if (second == null) {
allFieldNames = firstFields.keySet();
} else {
allFieldNames = getAllFields(firstFields.keySet(), secondFields.keySet());
allFieldNames = getAllFieldNames(firstFields.keySet(), secondFields.keySet());
}
List<FieldInfo> diffFields = new LinkedList<>();
for (String fieldName : allFieldNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public List<FieldInfo> getDiffFields(Object first, Object second) {
} else if (second == null) {
allFieldNames = firstGetters.keySet();
} else {
allFieldNames = getAllFields(firstGetters.keySet(), secondGetters.keySet());
allFieldNames = getAllFieldNames(firstGetters.keySet(), secondGetters.keySet());
}
List<FieldInfo> diffFields = new LinkedList<>();
for (String fieldName : allFieldNames) {
Expand Down

0 comments on commit 727e167

Please sign in to comment.