made getmethod more generic, added static string variable to terserUtil

This commit is contained in:
long 2021-03-19 08:41:41 -06:00
parent 6c41ded507
commit 08ab582c36
1 changed files with 6 additions and 4 deletions

View File

@ -47,6 +47,8 @@ public final class TerserUtil {
public static final String FIELD_NAME_IDENTIFIER = "identifier";
private static final String EQUALS_DEEP="equalsDeep";
public static final Collection<String> IDS_AND_META_EXCLUDES =
Collections.unmodifiableSet(Stream.of("id", "identifier", "meta").collect(Collectors.toSet()));
@ -158,10 +160,10 @@ public final class TerserUtil {
});
}
private static Method getMethod(IBase item){
private static Method getMethod(IBase item, String methodName){
Method method = null;
for (Method m : item.getClass().getDeclaredMethods()) {
if (m.getName().equals("equalsDeep")) {
if (m.getName().equals(methodName)) {
method = m;
break;
}
@ -170,7 +172,7 @@ public final class TerserUtil {
}
public static boolean equals(IBase theItem1, IBase theItem2){
final Method m = getMethod(theItem1);
final Method m = getMethod(theItem1, EQUALS_DEEP);
return equals(theItem1, theItem2, m);
}
@ -187,7 +189,7 @@ public final class TerserUtil {
}
private static boolean contains(IBase theItem, List<IBase> theItems) {
final Method m = getMethod(theItem);
final Method m = getMethod(theItem, EQUALS_DEEP);
return theItems.stream().anyMatch(i -> equals(i, theItem, m));
}