From 19612d4134c6000644fda0539a47211d577d116f Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 15 Sep 2022 15:28:00 -0400 Subject: [LANG-1691] ClassUtils.getShortCanonicalName doesn't use the canonicalName #949 --- src/main/java/org/apache/commons/lang3/ClassUtils.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/apache/commons/lang3/ClassUtils.java b/src/main/java/org/apache/commons/lang3/ClassUtils.java index 2e37d54d3..9e8f5f6ad 100644 --- a/src/main/java/org/apache/commons/lang3/ClassUtils.java +++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java @@ -808,12 +808,10 @@ public class ClassUtils { * @param cls the class for which to get the short canonical class name; may be null * @return the canonical name without the package name or an empty string * @since 2.4 + * @see Class#getCanonicalName() */ public static String getShortCanonicalName(final Class cls) { - if (cls == null) { - return StringUtils.EMPTY; - } - return getShortCanonicalName(cls.getCanonicalName()); + return cls == null ? StringUtils.EMPTY : getShortCanonicalName(cls.getCanonicalName()); } /** @@ -823,12 +821,10 @@ public class ClassUtils { * @param valueIfNull the value to return if null * @return the canonical name of the object without the package name, or the null value * @since 2.4 + * @see Class#getCanonicalName() */ public static String getShortCanonicalName(final Object object, final String valueIfNull) { - if (object == null) { - return valueIfNull; - } - return getShortCanonicalName(object.getClass().getCanonicalName()); + return object == null ? valueIfNull : getShortCanonicalName(object.getClass().getCanonicalName()); } /** -- cgit v1.2.3