You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/08/27 20:18:21 UTC

[commons-lang] branch master updated: Inline single use local variables.

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 c45f0b8  Inline single use local variables.
c45f0b8 is described below

commit c45f0b8a5b536e1fca43359bf4be5264bbe2409f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Aug 27 16:18:19 2021 -0400

    Inline single use local variables.
    
    Minor Javadoc tweak.
---
 .../commons/lang3/reflect/ConstructorUtils.java    |  6 ++---
 .../apache/commons/lang3/reflect/FieldUtils.java   |  6 ++---
 .../apache/commons/lang3/reflect/MemberUtils.java  |  2 +-
 .../apache/commons/lang3/reflect/MethodUtils.java  | 26 ++++++++--------------
 4 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
index 5ba9380..ecfdc37 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
@@ -80,8 +80,7 @@ public class ConstructorUtils {
             throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
             InstantiationException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeConstructor(cls, args, parameterTypes);
+        return invokeConstructor(cls, args, ClassUtils.toClass(args));
     }
 
     /**
@@ -144,8 +143,7 @@ public class ConstructorUtils {
             throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
             InstantiationException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeExactConstructor(cls, args, parameterTypes);
+        return invokeExactConstructor(cls, args, ClassUtils.toClass(args));
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
index 69ce9ec..612a46a 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
@@ -196,8 +196,7 @@ public class FieldUtils {
      * @since 3.2
      */
     public static Field[] getAllFields(final Class<?> cls) {
-        final List<Field> allFieldsList = getAllFieldsList(cls);
-        return allFieldsList.toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
+        return getAllFieldsList(cls).toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
     }
 
     /**
@@ -234,8 +233,7 @@ public class FieldUtils {
      * @since 3.4
      */
     public static Field[] getFieldsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) {
-        final List<Field> annotatedFieldsList = getFieldsListWithAnnotation(cls, annotationCls);
-        return annotatedFieldsList.toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
+        return getFieldsListWithAnnotation(cls, annotationCls).toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
index 3a8ffff..177c55f 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
@@ -40,7 +40,7 @@ abstract class MemberUtils {
             Character.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE };
 
     /**
-     * XXX Default access superclass workaround.
+     * Default access superclass workaround.
      *
      * When a {@code public} class has a default access superclass with {@code public} members,
      * these members are accessible. Calling them from compiled code works fine.
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 6c0c10d..a214b6c 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -150,8 +150,7 @@ public class MethodUtils {
             Object... args) throws NoSuchMethodException,
             IllegalAccessException, InvocationTargetException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeMethod(object, methodName, args, parameterTypes);
+        return invokeMethod(object, methodName, args, ClassUtils.toClass(args));
     }
 
     /**
@@ -181,8 +180,7 @@ public class MethodUtils {
             Object... args) throws NoSuchMethodException,
             IllegalAccessException, InvocationTargetException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeMethod(object, forceAccess, methodName, args, parameterTypes);
+        return invokeMethod(object, forceAccess, methodName, args, ClassUtils.toClass(args));
     }
 
     /**
@@ -307,8 +305,7 @@ public class MethodUtils {
             Object... args) throws NoSuchMethodException,
             IllegalAccessException, InvocationTargetException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeExactMethod(object, methodName, args, parameterTypes);
+        return invokeExactMethod(object, methodName, args, ClassUtils.toClass(args));
     }
 
     /**
@@ -407,8 +404,7 @@ public class MethodUtils {
             Object... args) throws NoSuchMethodException,
             IllegalAccessException, InvocationTargetException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeStaticMethod(cls, methodName, args, parameterTypes);
+        return invokeStaticMethod(cls, methodName, args, ClassUtils.toClass(args));
     }
 
     /**
@@ -522,8 +518,7 @@ public class MethodUtils {
             Object... args) throws NoSuchMethodException,
             IllegalAccessException, InvocationTargetException {
         args = ArrayUtils.nullToEmpty(args);
-        final Class<?>[] parameterTypes = ClassUtils.toClass(args);
-        return invokeExactStaticMethod(cls, methodName, args, parameterTypes);
+        return invokeExactStaticMethod(cls, methodName, args, ClassUtils.toClass(args));
     }
 
     /**
@@ -539,10 +534,9 @@ public class MethodUtils {
      * @return The accessible method
      */
     public static Method getAccessibleMethod(final Class<?> cls, final String methodName,
-            final Class<?>... parameterTypes) {
+        final Class<?>... parameterTypes) {
         try {
-            return getAccessibleMethod(cls.getMethod(methodName,
-                    parameterTypes));
+            return getAccessibleMethod(cls.getMethod(methodName, parameterTypes));
         } catch (final NoSuchMethodException e) {
             return null;
         }
@@ -909,10 +903,8 @@ public class MethodUtils {
      * @since 3.6
      */
     public static Method[] getMethodsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls,
-                                                    final boolean searchSupers, final boolean ignoreAccess) {
-        final List<Method> annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls, searchSupers,
-                ignoreAccess);
-        return annotatedMethodsList.toArray(ArrayUtils.EMPTY_METHOD_ARRAY);
+        final boolean searchSupers, final boolean ignoreAccess) {
+        return getMethodsListWithAnnotation(cls, annotationCls, searchSupers, ignoreAccess).toArray(ArrayUtils.EMPTY_METHOD_ARRAY);
     }
 
     /**