Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chia7712 committed Mar 8, 2024
1 parent 94aade6 commit da0e149
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions common/src/main/java/org/astraea/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,18 +420,13 @@ private static Object reflectionAttribute(Class<?> clz, Object object, String at
}

private static Object reflectionMethod(Class<?> clz, Object object, String attribute) {
do {
try {
var method = clz.getDeclaredMethod(attribute);
method.setAccessible(true);
return method.invoke(object);
} catch (NoSuchMethodException e) {
clz = clz.getSuperclass();
} catch (Exception e) {
throw new RuntimeException(e);
}
} while (clz != null);
throw new RuntimeException(attribute + " is not existent in " + object.getClass().getName());
try {
var method = clz.getDeclaredMethod(attribute);
method.setAccessible(true);
return method.invoke(object);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public static <T> List<T> constants(
Expand Down

0 comments on commit da0e149

Please sign in to comment.