change logic to always give objects the highest value

This commit is contained in:
tueem 2024-12-02 21:20:49 +01:00
parent 7f47130461
commit 94da2a0e3c
Signed by: tueem
GPG Key ID: 65C8667EC17A88FB

@ -23,6 +23,10 @@ public final class ReflectionUtil {
}
public static int getCastDepth(Class<?> child, Class<?> parent) {
if (parent.equals(Object.class))
return Integer.MAX_VALUE;
if (!parent.isAssignableFrom(child)) {
throw new IllegalArgumentException("The specified class is not a child class of the specified parent.");
}
@ -77,7 +81,7 @@ public final class ReflectionUtil {
Class<?> currMostSpecific = null;
for (Class<?> currClass : classes) {
int currCastDepth = getCastDepth(base, currClass);
if (currCastDepth < min) {
if (currCastDepth <= min) {
min = currCastDepth;
currMostSpecific = currClass;
}