This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new 897f2e3 Drop useless parens and use lambda. 897f2e3 is described below commit 897f2e37ec6655e83e9eb2783cdc1a881054e6bf Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Nov 18 22:06:25 2021 -0500 Drop useless parens and use lambda. --- .../org/apache/commons/lang3/reflect/MethodUtils.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 4992ee4..eff0ee8 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -684,7 +684,7 @@ public class MethodUtils { // compare name and parameters if (method.getName().equals(methodName) && MemberUtils.isMatchingMethod(method, parameterTypes)) { - matchingMethods.add (method); + matchingMethods.add(method); } } @@ -712,8 +712,8 @@ public class MethodUtils { final String methodParameterComponentTypeName = ClassUtils.primitiveToWrapper(methodParameterComponentType).getName(); final Class<?> lastParameterType = parameterTypes[parameterTypes.length - 1]; - final String parameterTypeName = (lastParameterType==null) ? null : lastParameterType.getName(); - final String parameterTypeSuperClassName = (lastParameterType==null) ? null : lastParameterType.getSuperclass().getName(); + final String parameterTypeName = lastParameterType==null ? null : lastParameterType.getName(); + final String parameterTypeSuperClassName = lastParameterType==null ? null : lastParameterType.getSuperclass().getName(); if (parameterTypeName!= null && parameterTypeSuperClassName != null && !methodParameterComponentTypeName.equals(parameterTypeName) && !methodParameterComponentTypeName.equals(parameterTypeSuperClassName)) { @@ -930,12 +930,8 @@ public class MethodUtils { classes.add(0, cls); final List<Method> annotatedMethods = new ArrayList<>(); for (final Class<?> acls : classes) { - final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods()); - for (final Method method : methods) { - if (method.getAnnotation(annotationCls) != null) { - annotatedMethods.add(method); - } - } + final Method[] methods = ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods(); + Stream.of(methods).filter(method -> method.isAnnotationPresent(annotationCls)).forEachOrdered(annotatedMethods::add); } return annotatedMethods; } @@ -977,8 +973,8 @@ public class MethodUtils { final Class<?> mcls = method.getDeclaringClass(); final List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls); for (final Class<?> acls : classes) { - final Method equivalentMethod = (ignoreAccess ? MethodUtils.getMatchingMethod(acls, method.getName(), method.getParameterTypes()) - : MethodUtils.getMatchingAccessibleMethod(acls, method.getName(), method.getParameterTypes())); + final Method equivalentMethod = ignoreAccess ? MethodUtils.getMatchingMethod(acls, method.getName(), method.getParameterTypes()) + : MethodUtils.getMatchingAccessibleMethod(acls, method.getName(), method.getParameterTypes()); if (equivalentMethod != null) { annotation = equivalentMethod.getAnnotation(annotationCls); if (annotation != null) {