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 2025/08/30 13:04:58 UTC

(commons-lang) 07/10: Use ternary.

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

commit bdbc6cb42937142995a093cfa691debf37ddef57
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 30 07:54:26 2025 -0400

    Use ternary.
---
 src/main/java/org/apache/commons/lang3/ClassUtils.java | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/ClassUtils.java b/src/main/java/org/apache/commons/lang3/ClassUtils.java
index ea07dee3c..011f7b99b 100644
--- a/src/main/java/org/apache/commons/lang3/ClassUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java
@@ -1465,16 +1465,11 @@ public static Class<?>[] primitivesToWrappers(final Class<?>... classes) {
      * </p>
      *
      * @param cls the class to convert, may be null.
-     * @return the wrapper class for {@code cls} or {@code cls} if {@code cls} is not a primitive. {@code null} if null
-     *         input.
+     * @return the wrapper class for {@code cls} or {@code cls} if {@code cls} is not a primitive. {@code null} if null input.
      * @since 2.1
      */
     public static Class<?> primitiveToWrapper(final Class<?> cls) {
-        Class<?> convertedClass = cls;
-        if (cls != null && cls.isPrimitive()) {
-            convertedClass = PRIMITIVE_WRAPPER_MAP.get(cls);
-        }
-        return convertedClass;
+        return cls != null && cls.isPrimitive() ? PRIMITIVE_WRAPPER_MAP.get(cls) : cls;
     }
 
     /**