diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TerserUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TerserUtil.java index 75266c1de53..46af6925776 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TerserUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TerserUtil.java @@ -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 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 theItems) { - final Method m = getMethod(theItem); + final Method m = getMethod(theItem, EQUALS_DEEP); return theItems.stream().anyMatch(i -> equals(i, theItem, m)); }