0

fix полечение метода

This commit is contained in:
2021-01-08 16:39:33 +03:00
parent aab3b43e57
commit 8e97d33be4

View File

@@ -84,17 +84,41 @@ public class ReflectionObject {
}
}
public List<ReflectionMethod> methodsAllList() {
final Class clazz = object.getClass();
Method[] declaredMethods = clazz.getMethods();
if (declaredMethods.length > 0) {
List<ReflectionMethod> result = new ArrayList<>(declaredMethods.length);
for (Method method : declaredMethods) {
result.add(new ReflectionMethod(object, method));
}
return result;
} else {
return Collections.emptyList();
}
}
@SuppressWarnings("unchecked")
public ReflectionMethod method(String methodName, Class<?>... parameterTypes) {
final Class clazz = object.getClass();
Method method;
try {
return new ReflectionMethod(object, clazz.getDeclaredMethod(methodName, parameterTypes));
method = clazz.getDeclaredMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
throw new ReflectionException(e);
try {
method = clazz.getMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e1) {
throw new ReflectionException(e1);
}
}
return new ReflectionMethod(object, method);
}
@Override
public boolean equals(final Object o) {
if (o == this) return true;