Skip to content

Commit

Permalink
Support interfaces previously enums
Browse files Browse the repository at this point in the history
  • Loading branch information
kangarko committed Jan 7, 2025
1 parent fe53c7f commit 792f681
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/org/mineacademy/fo/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,16 @@ public static <E> E lookupEnumSilent(final Class<E> enumClass, final String name
} catch (final Throwable t) {
}

if (method == null)
try {
method = enumClass.getDeclaredMethod("valueOf", String.class);

if (Modifier.isPublic(method.getModifiers()) && Modifier.isStatic(method.getModifiers()))
hasKey = true;

} catch (final NoSuchMethodException t) {
}

if (hasKey)
return (E) method.invoke(null, name);

Expand Down Expand Up @@ -1223,16 +1233,16 @@ public Constructor<T> getConstructor(final Class<?>... paramTypes) throws NoSuch
/*public Method getDeclaredMethod(final String name, final Class<?>... paramTypes) throws NoSuchMethodException {
if (methodCache.containsKey(name)) {
final Collection<Method> methods = methodCache.get(name);
for (final Method method : methods)
if (Arrays.equals(paramTypes, method.getParameterTypes()))
return method;
}
final Method method = clazz.getDeclaredMethod(name, paramTypes);
cacheMethod(method);
return method;
}*/

Expand Down

0 comments on commit 792f681

Please sign in to comment.