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 139a25afe Internal refactoring
139a25afe is described below

commit 139a25afec3de06e42fdd3a7dca794bc839e9b56
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sun Jun 22 08:55:43 2025 -0400

    Internal refactoring
---
 .../apache/commons/lang3/reflect/TypeUtils.java    | 26 +++++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java 
b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
index d84ef4830..a1fe217e8 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
@@ -646,14 +646,11 @@ private static Type getClosestParentType(final Class<?> 
cls, final Class<?> supe
      * {@link TypeVariable#getBounds()} passed into {@link 
#normalizeUpperBounds}.
      *
      * @param typeVariable the subject type variable, not {@code null}
-     * @return a non-empty array containing the bounds of the type variable.
+     * @return a non-empty array containing the bounds of the type variable, 
which could be {@link Object}.
      * @throws NullPointerException if {@code typeVariable} is {@code null}
      */
     public static Type[] getImplicitBounds(final TypeVariable<?> typeVariable) 
{
-        Objects.requireNonNull(typeVariable, "typeVariable");
-        final Type[] bounds = typeVariable.getBounds();
-
-        return bounds.length == 0 ? new Type[] { Object.class } : 
normalizeUpperBounds(bounds);
+        return normalizeUpperToObject(Objects.requireNonNull(typeVariable, 
"typeVariable").getBounds());
     }
 
     /**
@@ -661,13 +658,12 @@ public static Type[] getImplicitBounds(final 
TypeVariable<?> typeVariable) {
      * of {@link WildcardType#getLowerBounds()}.
      *
      * @param wildcardType the subject wildcard type, not {@code null}
-     * @return a non-empty array containing the lower bounds of the wildcard 
type.
+     * @return a non-empty array containing the lower bounds of the wildcard 
type, which could be null.
      * @throws NullPointerException if {@code wildcardType} is {@code null}
      */
     public static Type[] getImplicitLowerBounds(final WildcardType 
wildcardType) {
         Objects.requireNonNull(wildcardType, "wildcardType");
         final Type[] bounds = wildcardType.getLowerBounds();
-
         return bounds.length == 0 ? new Type[] { null } : bounds;
     }
 
@@ -680,10 +676,7 @@ public static Type[] getImplicitLowerBounds(final 
WildcardType wildcardType) {
      * @throws NullPointerException if {@code wildcardType} is {@code null}
      */
     public static Type[] getImplicitUpperBounds(final WildcardType 
wildcardType) {
-        Objects.requireNonNull(wildcardType, "wildcardType");
-        final Type[] bounds = wildcardType.getUpperBounds();
-
-        return bounds.length == 0 ? new Type[] { Object.class } : 
normalizeUpperBounds(bounds);
+        return normalizeUpperToObject(Objects.requireNonNull(wildcardType, 
"wildcardType").getUpperBounds());
     }
 
     /**
@@ -1372,6 +1365,17 @@ public static Type[] normalizeUpperBounds(final Type[] 
bounds) {
         return types.toArray(ArrayUtils.EMPTY_TYPE_ARRAY);
     }
 
+    /**
+     * Delegates to {@link #normalizeUpperBounds(Type[])} unless {@code 
bounds} is empty in which case return an array with the element {@code 
Object.class}.
+     *
+     * @param bounds bounds an array of types representing the upper bounds of 
either {@link WildcardType} or {@link TypeVariable}, not {@code null}.
+     * @return result from {@link #normalizeUpperBounds(Type[])} unless {@code 
bounds} is empty in which case return an array with the element
+     *         {@code Object.class}.
+     */
+    private static Type[] normalizeUpperToObject(final Type[] bounds) {
+        return bounds.length == 0 ? new Type[] { Object.class } : 
normalizeUpperBounds(bounds);
+    }
+
     /**
      * Creates a parameterized type instance.
      *

Reply via email to