Drop useless parens and use lambda.

This commit is contained in:
Gary Gregory 2021-11-18 22:06:25 -05:00
parent adacce00cd
commit 897f2e37ec

View File

@ -684,7 +684,7 @@ public static Method getMatchingAccessibleMethod(final Class<?> cls,
// compare name and parameters // compare name and parameters
if (method.getName().equals(methodName) && if (method.getName().equals(methodName) &&
MemberUtils.isMatchingMethod(method, parameterTypes)) { MemberUtils.isMatchingMethod(method, parameterTypes)) {
matchingMethods.add (method); matchingMethods.add(method);
} }
} }
@ -712,8 +712,8 @@ public static Method getMatchingAccessibleMethod(final Class<?> cls,
final String methodParameterComponentTypeName = ClassUtils.primitiveToWrapper(methodParameterComponentType).getName(); final String methodParameterComponentTypeName = ClassUtils.primitiveToWrapper(methodParameterComponentType).getName();
final Class<?> lastParameterType = parameterTypes[parameterTypes.length - 1]; final Class<?> lastParameterType = parameterTypes[parameterTypes.length - 1];
final String parameterTypeName = (lastParameterType==null) ? null : lastParameterType.getName(); final String parameterTypeName = lastParameterType==null ? null : lastParameterType.getName();
final String parameterTypeSuperClassName = (lastParameterType==null) ? null : lastParameterType.getSuperclass().getName(); final String parameterTypeSuperClassName = lastParameterType==null ? null : lastParameterType.getSuperclass().getName();
if (parameterTypeName!= null && parameterTypeSuperClassName != null && !methodParameterComponentTypeName.equals(parameterTypeName) if (parameterTypeName!= null && parameterTypeSuperClassName != null && !methodParameterComponentTypeName.equals(parameterTypeName)
&& !methodParameterComponentTypeName.equals(parameterTypeSuperClassName)) { && !methodParameterComponentTypeName.equals(parameterTypeSuperClassName)) {
@ -930,12 +930,8 @@ public static List<Method> getMethodsListWithAnnotation(final Class<?> cls,
classes.add(0, cls); classes.add(0, cls);
final List<Method> annotatedMethods = new ArrayList<>(); final List<Method> annotatedMethods = new ArrayList<>();
for (final Class<?> acls : classes) { for (final Class<?> acls : classes) {
final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods()); final Method[] methods = ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods();
for (final Method method : methods) { Stream.of(methods).filter(method -> method.isAnnotationPresent(annotationCls)).forEachOrdered(annotatedMethods::add);
if (method.getAnnotation(annotationCls) != null) {
annotatedMethods.add(method);
}
}
} }
return annotatedMethods; return annotatedMethods;
} }
@ -977,8 +973,8 @@ public static <A extends Annotation> A getAnnotation(final Method method, final
final Class<?> mcls = method.getDeclaringClass(); final Class<?> mcls = method.getDeclaringClass();
final List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls); final List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls);
for (final Class<?> acls : classes) { for (final Class<?> acls : classes) {
final Method equivalentMethod = (ignoreAccess ? MethodUtils.getMatchingMethod(acls, method.getName(), method.getParameterTypes()) final Method equivalentMethod = ignoreAccess ? MethodUtils.getMatchingMethod(acls, method.getName(), method.getParameterTypes())
: MethodUtils.getMatchingAccessibleMethod(acls, method.getName(), method.getParameterTypes())); : MethodUtils.getMatchingAccessibleMethod(acls, method.getName(), method.getParameterTypes());
if (equivalentMethod != null) { if (equivalentMethod != null) {
annotation = equivalentMethod.getAnnotation(annotationCls); annotation = equivalentMethod.getAnnotation(annotationCls);
if (annotation != null) { if (annotation != null) {