Inline single use local variables.

Minor Javadoc tweak.
This commit is contained in:
Gary Gregory 2021-08-27 16:18:19 -04:00
parent 94ffa01a03
commit c45f0b8a5b
4 changed files with 14 additions and 26 deletions

View File

@ -80,8 +80,7 @@ public class ConstructorUtils {
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException { InstantiationException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeConstructor(cls, args, ClassUtils.toClass(args));
return invokeConstructor(cls, args, parameterTypes);
} }
/** /**
@ -144,8 +143,7 @@ public class ConstructorUtils {
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException { InstantiationException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeExactConstructor(cls, args, ClassUtils.toClass(args));
return invokeExactConstructor(cls, args, parameterTypes);
} }
/** /**

View File

@ -196,8 +196,7 @@ public class FieldUtils {
* @since 3.2 * @since 3.2
*/ */
public static Field[] getAllFields(final Class<?> cls) { public static Field[] getAllFields(final Class<?> cls) {
final List<Field> allFieldsList = getAllFieldsList(cls); return getAllFieldsList(cls).toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
return allFieldsList.toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
} }
/** /**
@ -234,8 +233,7 @@ public class FieldUtils {
* @since 3.4 * @since 3.4
*/ */
public static Field[] getFieldsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) { public static Field[] getFieldsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) {
final List<Field> annotatedFieldsList = getFieldsListWithAnnotation(cls, annotationCls); return getFieldsListWithAnnotation(cls, annotationCls).toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
return annotatedFieldsList.toArray(ArrayUtils.EMPTY_FIELD_ARRAY);
} }
/** /**

View File

@ -40,7 +40,7 @@ abstract class MemberUtils {
Character.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE }; 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, * 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. * these members are accessible. Calling them from compiled code works fine.

View File

@ -150,8 +150,7 @@ public class MethodUtils {
Object... args) throws NoSuchMethodException, Object... args) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException { IllegalAccessException, InvocationTargetException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeMethod(object, methodName, args, ClassUtils.toClass(args));
return invokeMethod(object, methodName, args, parameterTypes);
} }
/** /**
@ -181,8 +180,7 @@ public class MethodUtils {
Object... args) throws NoSuchMethodException, Object... args) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException { IllegalAccessException, InvocationTargetException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeMethod(object, forceAccess, methodName, args, ClassUtils.toClass(args));
return invokeMethod(object, forceAccess, methodName, args, parameterTypes);
} }
/** /**
@ -307,8 +305,7 @@ public class MethodUtils {
Object... args) throws NoSuchMethodException, Object... args) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException { IllegalAccessException, InvocationTargetException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeExactMethod(object, methodName, args, ClassUtils.toClass(args));
return invokeExactMethod(object, methodName, args, parameterTypes);
} }
/** /**
@ -407,8 +404,7 @@ public class MethodUtils {
Object... args) throws NoSuchMethodException, Object... args) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException { IllegalAccessException, InvocationTargetException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeStaticMethod(cls, methodName, args, ClassUtils.toClass(args));
return invokeStaticMethod(cls, methodName, args, parameterTypes);
} }
/** /**
@ -522,8 +518,7 @@ public class MethodUtils {
Object... args) throws NoSuchMethodException, Object... args) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException { IllegalAccessException, InvocationTargetException {
args = ArrayUtils.nullToEmpty(args); args = ArrayUtils.nullToEmpty(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeExactStaticMethod(cls, methodName, args, ClassUtils.toClass(args));
return invokeExactStaticMethod(cls, methodName, args, parameterTypes);
} }
/** /**
@ -539,10 +534,9 @@ public class MethodUtils {
* @return The accessible method * @return The accessible method
*/ */
public static Method getAccessibleMethod(final Class<?> cls, final String methodName, public static Method getAccessibleMethod(final Class<?> cls, final String methodName,
final Class<?>... parameterTypes) { final Class<?>... parameterTypes) {
try { try {
return getAccessibleMethod(cls.getMethod(methodName, return getAccessibleMethod(cls.getMethod(methodName, parameterTypes));
parameterTypes));
} catch (final NoSuchMethodException e) { } catch (final NoSuchMethodException e) {
return null; return null;
} }
@ -909,10 +903,8 @@ public class MethodUtils {
* @since 3.6 * @since 3.6
*/ */
public static Method[] getMethodsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls, public static Method[] getMethodsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls,
final boolean searchSupers, final boolean ignoreAccess) { final boolean searchSupers, final boolean ignoreAccess) {
final List<Method> annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls, searchSupers, return getMethodsListWithAnnotation(cls, annotationCls, searchSupers, ignoreAccess).toArray(ArrayUtils.EMPTY_METHOD_ARRAY);
ignoreAccess);
return annotatedMethodsList.toArray(ArrayUtils.EMPTY_METHOD_ARRAY);
} }
/** /**