]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Fix bug in ReflectionHelper
authorIrtimaled <irtimaled@gmail.com>
Thu, 4 Jun 2020 22:24:08 +0000 (15:24 -0700)
committerIrtimaled <irtimaled@gmail.com>
Tue, 9 Jun 2020 05:34:15 +0000 (22:34 -0700)
src/main/java/com/irtimaled/bbor/common/ReflectionHelper.java

index 4ade3c2a4e7306b82c6c39156526cb623689bc32..29117518e6ff45919db043726dd898fed48eb022 100644 (file)
@@ -33,14 +33,21 @@ public class ReflectionHelper {
             if (rawType != fieldType) continue;
 
             Type[] actualTypeArguments = genericType.getActualTypeArguments();
-            if (actualTypeArguments.length != genericTypeArguments.length) continue;
-
-            for (int typeIndex = 0; typeIndex < actualTypeArguments.length; typeIndex++) {
-                if (actualTypeArguments[typeIndex] != genericTypeArguments[typeIndex]) return null;
-            }
+            if (!typesMatch(genericTypeArguments, actualTypeArguments)) continue;
 
             return field;
         }
         return null;
     }
+
+    private static boolean typesMatch(Type[] left, Type[] right) {
+        if (left.length != right.length) return false;
+
+        for (int index = 0; index < right.length; index++) {
+            if (right[index] != left[index]) {
+                return false;
+            }
+        }
+        return true;
+    }
 }