ClassUtils (Apache Commons Lang 3.20.0 API)
Description: declaration: package: org.apache.commons.lang3, class: ClassUtils

# Class ClassUtils

java.lang.Object
org.apache.commons.lang3.ClassUtils

public class ClassUtils extends Object
Operates on classes without using reflection.

This class handles invalid `null` inputs as best it can. Each method documents its behavior in more detail.

The notion of a `canonical name` includes the human-readable name for the type, for example `int[]`. The non-canonical method variants work with the JVM names, such as `[I`.

Since:
  2.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `ClassUtils.Interfaces`
  Inclusivity literals for `hierarchy(Class, Interfaces)`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `INNER_CLASS_SEPARATOR`
  The inner class separator String: `"$"`.
  `static final char`
  `INNER_CLASS_SEPARATOR_CHAR`
  The inner class separator character: `'$' == {@value}`.
  `static final String`
  `PACKAGE_SEPARATOR`
  The package separator String: `"&#x2e;"`.
  `static final char`
  `PACKAGE_SEPARATOR_CHAR`
  The package separator character: `'&#x2e;' == {@value}`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClassUtils()`
  Deprecated.
  TODO Make private in 4.0.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Comparator<Class<?>>`
  `comparator()`
  Gets the class comparator, comparing by class name.
  `static List<String>`
  `convertClassesToClassNames(List<Class<?>> classes)`
  Given a `List` of `Class` objects, this method converts them into class names.
  `static List<Class<?>>`
  `convertClassNamesToClasses(List<String> classNames)`
  Given a `List` of class names, this method converts them into classes.
  `static String`
  `getAbbreviatedName(Class<?> cls, int lengthHint)`
  Gets the abbreviated name of a `Class`.
  `static String`
  `getAbbreviatedName(String className, int lengthHint)`
  Gets the abbreviated class name from a `String`.
  `static List<Class<?>>`
  `getAllInterfaces(Class<?> cls)`
  Gets a `List` of all interfaces implemented by the given class and its superclasses.
  `static List<Class<?>>`
  `getAllSuperclasses(Class<?> cls)`
  Gets a `List` of superclasses for the given class.
  `static String`
  `getCanonicalName(Class<?> cls)`
  Gets the canonical class name for a `Class`.
  `static String`
  `getCanonicalName(Class<?> cls, String valueIfNull)`
  Gets the canonical name for a `Class`.
  `static String`
  `getCanonicalName(Object object)`
  Gets the canonical name for an `Object`.
  `static String`
  `getCanonicalName(Object object, String valueIfNull)`
  Gets the canonical name for an `Object`.
  `static Class<?>`
  `getClass(ClassLoader classLoader, String className)`
  Gets the (initialized) class represented by `className` using the `classLoader`.
  `static Class<?>`
  `getClass(ClassLoader classLoader, String className, boolean initialize)`
  Gets the class represented by `className` using the `classLoader`.
  `static Class<?>`
  `getClass(String className)`
  Gets the (initialized) class represented by `className` using the current thread's context class loader.
  `static Class<?>`
  `getClass(String className, boolean initialize)`
  Gets the class represented by `className` using the current thread's context class loader.
  `static <T> Class<T>`
  `getComponentType(Class<T[]> cls)`
  Delegates to `Class.getComponentType()` using generics.
  `static String`
  `getName(Class<?> cls)`
  Null-safe version of `cls.getName()`
  `static String`
  `getName(Class<?> cls, String valueIfNull)`
  Null-safe version of `cls.getName()`
  `static String`
  `getName(Object object)`
  Null-safe version of `object.getClass().getName()`
  `static String`
  `getName(Object object, String valueIfNull)`
  Null-safe version of `object.getClass().getSimpleName()`
  `static String`
  `getPackageCanonicalName(Class<?> cls)`
  Gets the package name from the canonical name of a `Class`.
  `static String`
  `getPackageCanonicalName(Object object, String valueIfNull)`
  Gets the package name from the class name of an `Object`.
  `static String`
  `getPackageCanonicalName(String name)`
  Gets the package name from the class name.
  `static String`
  `getPackageName(Class<?> cls)`
  Gets the package name of a `Class`.
  `static String`
  `getPackageName(Object object, String valueIfNull)`
  Gets the package name of an `Object`.
  `static String`
  `getPackageName(String className)`
  Gets the package name from a `String`.
  `static Method`
  `getPublicMethod(Class<?> cls, String methodName, Class<?>... parameterTypes)`
  Gets the desired Method much like `Class.getMethod`, however it ensures that the returned Method is from a public class or interface and not from an anonymous inner class.
  `static String`
  `getShortCanonicalName(Class<?> cls)`
  Gets the canonical name minus the package name from a `Class`.
  `static String`
  `getShortCanonicalName(Object object, String valueIfNull)`
  Gets the canonical name minus the package name for an `Object`.
  `static String`
  `getShortCanonicalName(String canonicalName)`
  Gets the canonical name minus the package name from a String.
  `static String`
  `getShortClassName(Class<?> cls)`
  Gets the class name minus the package name from a `Class`.
  `static String`
  `getShortClassName(Object object, String valueIfNull)`
  Gets the class name of the `object` without the package name or names.
  `static String`
  `getShortClassName(String className)`
  Gets the class name minus the package name from a String.
  `static String`
  `getSimpleName(Class<?> cls)`
  Null-safe version of `cls.getSimpleName()`
  `static String`
  `getSimpleName(Class<?> cls, String valueIfNull)`
  Null-safe version of `cls.getSimpleName()`
  `static String`
  `getSimpleName(Object object)`
  Null-safe version of `object.getClass().getSimpleName()`
  `static String`
  `getSimpleName(Object object, String valueIfNull)`
  Null-safe version of `object.getClass().getSimpleName()`
  `static Iterable<Class<?>>`
  `hierarchy(Class<?> type)`
  Gets an `Iterable` that can iterate over a class hierarchy in ascending (subclass to superclass) order, excluding interfaces.
  `static Iterable<Class<?>>`
  `hierarchy(Class<?> type, ClassUtils.Interfaces interfacesBehavior)`
  Gets an `Iterable` that can iterate over a class hierarchy in ascending (subclass to superclass) order.
  `static boolean`
  `isAssignable(Class<?>[] classArray, Class<?>... toClassArray)`
  Tests whether an array of Classes can be assigned to another array of Classes.
  `static boolean`
  `isAssignable(Class<?>[] classArray, Class<?>[] toClassArray, boolean autoboxing)`
  Tests whether an array of Classes can be assigned to another array of Classes.
  `static boolean`
  `isAssignable(Class<?> cls, Class<?> toClass)`
  Tests whether one `Class` can be assigned to a variable of another `Class`.
  `static boolean`
  `isAssignable(Class<?> cls, Class<?> toClass, boolean autoboxing)`
  Tests whether one `Class` can be assigned to a variable of another `Class`.
  `static boolean`
  `isInnerClass(Class<?> cls)`
  Tests whether the specified class an inner class or static nested class.
  `static boolean`
  `isPrimitiveOrWrapper(Class<?> type)`
  Tests whether the given `type` is a primitive or primitive wrapper (`Boolean`, `Byte`, `Character`, `Short`, `Integer`, `Long`, `Double`, `Float`).
  `static boolean`
  `isPrimitiveWrapper(Class<?> type)`
  Tests whether the given `type` is a primitive wrapper (`Boolean`, `Byte`, `Character`, `Short`, `Integer`, `Long`, `Double`, `Float`).
  `static boolean`
  `isPublic(Class<?> cls)`
  Tests whether a `Class` is public.
  `static Class<?>[]`
  `primitivesToWrappers(Class<?>... classes)`
  Converts the specified array of primitive Class objects to an array of its corresponding wrapper Class objects.
  `static Class<?>`
  `primitiveToWrapper(Class<?> cls)`
  Converts the specified primitive Class object to its corresponding wrapper Class object.
  `static Class<?>[]`
  `toClass(Object... array)`
  Converts an array of `Object` in to an array of `Class` objects.
  `static Class<?>[]`
  `wrappersToPrimitives(Class<?>... classes)`
  Converts the specified array of wrapper Class objects to an array of its corresponding primitive Class objects.
  `static Class<?>`
  `wrapperToPrimitive(Class<?> cls)`
  Converts the specified wrapper class to its corresponding primitive class.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PACKAGE_SEPARATOR_CHAR

    public static final char PACKAGE_SEPARATOR_CHAR
    The package separator character: `'&#x2e;' == {@value}`.
    See Also:
      - Constant Field Values

  - ### PACKAGE_SEPARATOR

    public static final String PACKAGE_SEPARATOR
    The package separator String: `"&#x2e;"`.

  - ### INNER_CLASS_SEPARATOR_CHAR

    public static final char INNER_CLASS_SEPARATOR_CHAR
    The inner class separator character: `'$' == {@value}`.
    See Also:
      - Constant Field Values

  - ### INNER_CLASS_SEPARATOR

    public static final String INNER_CLASS_SEPARATOR
    The inner class separator String: `"$"`.

- ## Constructor Details

  - ### ClassUtils

    @Deprecated public ClassUtils()
    Deprecated.
    TODO Make private in 4.0.
    ClassUtils instances should NOT be constructed in standard programming. Instead, the class should be used as `ClassUtils.getShortClassName(cls)`.

    This constructor is public to permit tools that require a JavaBean instance to operate.

- ## Method Details

  - ### comparator

    public static Comparator<Class<?>> comparator()
    Gets the class comparator, comparing by class name.
    Returns:
      the class comparator.
    Since:
      3.13.0

  - ### convertClassesToClassNames

    public static List<String> convertClassesToClassNames(List<Class<?>> classes)
    Given a `List` of `Class` objects, this method converts them into class names.

    A new `List` is returned. `null` objects will be copied into the returned list as `null`.

    Parameters:
      `classes` - the classes to change
    Returns:
      a `List` of class names corresponding to the Class objects, `null` if null input
    Throws:
      `ClassCastException` - if `classes` contains a non-`Class` entry

  - ### convertClassNamesToClasses

    public static List<Class<?>> convertClassNamesToClasses(List<String> classNames)
    Given a `List` of class names, this method converts them into classes.

    A new `List` is returned. If the class name cannot be found, `null` is stored in the `List`. If the class name in the `List` is `null`, `null` is stored in the output `List`.

    Parameters:
      `classNames` - the classNames to change
    Returns:
      a `List` of Class objects corresponding to the class names, `null` if null input
    Throws:
      `ClassCastException` - if classNames contains a non String entry

  - ### getAbbreviatedName

    public static String getAbbreviatedName(Class<?> cls, int lengthHint)
    Gets the abbreviated name of a `Class`.
    Parameters:
      `cls` - the class to get the abbreviated name for, may be `null`
      `lengthHint` - the desired length of the abbreviated name
    Returns:
      the abbreviated name or an empty string
    Throws:
      `IllegalArgumentException` - if len <= 0
    Since:
      3.4
    See Also:
      - `getAbbreviatedName(String, int)`

  - ### getAbbreviatedName

    public static String getAbbreviatedName(String className, int lengthHint)
    Gets the abbreviated class name from a `String`.

    The string passed in is assumed to be a class name - it is not checked.

    The abbreviation algorithm will shorten the class name, usually without significant loss of meaning.

    The abbreviated class name will always include the complete package hierarchy. If enough space is available, rightmost sub-packages will be displayed in full length. The abbreviated package names will be shortened to a single character.

    Only package names are shortened, the class simple name remains untouched. (See examples.)

    The result will be longer than the desired length only if all the package names shortened to a single character plus the class simple name with the separating dots together are longer than the desired length. In other words, when the class name cannot be shortened to the desired length.

    If the class name can be shortened then the final length will be at most `lengthHint` characters.

    If the `lengthHint` is zero or negative then the method throws exception. If you want to achieve the shortest possible version then use `1` as a `lengthHint`.

    Examples
    className | len | return
    null | 1 | ""
    "java.lang.String" | 5 | "j.l.String"
    "java.lang.String" | 15 | "j.lang.String"
    "java.lang.String" | 30 | "java.lang.String"
    "org.apache.commons.lang3.ClassUtils" | 18 | "o.a.c.l.ClassUtils"

    Parameters:
      `className` - the className to get the abbreviated name for, may be `null`
      `lengthHint` - the desired length of the abbreviated name
    Returns:
      the abbreviated name or an empty string if the specified class name is `null` or empty string. The abbreviated name may be longer than the desired length if it cannot be abbreviated to the desired length.
    Throws:
      `IllegalArgumentException` - if `len <= 0`
    Since:
      3.4

  - ### getAllInterfaces

    public static List<Class<?>> getAllInterfaces(Class<?> cls)
    Gets a `List` of all interfaces implemented by the given class and its superclasses.

    The order is determined by looking through each interface in turn as declared in the source file and following its hierarchy up. Then each superclass is considered in the same way. Later duplicates are ignored, so the order is maintained.

    Parameters:
      `cls` - the class to look up, may be `null`
    Returns:
      the `List` of interfaces in order, `null` if null input

  - ### getAllSuperclasses

    public static List<Class<?>> getAllSuperclasses(Class<?> cls)
    Gets a `List` of superclasses for the given class.
    Parameters:
      `cls` - the class to look up, may be `null`
    Returns:
      the `List` of superclasses in order going up from this one `null` if null input

  - ### getCanonicalName

    public static String getCanonicalName(Class<?> cls)
    Gets the canonical class name for a `Class`.
    Parameters:
      `cls` - the class for which to get the canonical class name; may be null
    Returns:
      the canonical name of the class, or the empty String
    Since:
      3.7
    See Also:
      - `Class.getCanonicalName()`

  - ### getCanonicalName

    public static String getCanonicalName(Class<?> cls, String valueIfNull)
    Gets the canonical name for a `Class`.
    Parameters:
      `cls` - the class for which to get the canonical class name; may be null
      `valueIfNull` - the return value if null
    Returns:
      the canonical name of the class, or `valueIfNull`
    Since:
      3.7
    See Also:
      - `Class.getCanonicalName()`

  - ### getCanonicalName

    public static String getCanonicalName(Object object)
    Gets the canonical name for an `Object`.
    Parameters:
      `object` - the object for which to get the canonical class name; may be null
    Returns:
      the canonical name of the object, or the empty String
    Since:
      3.7
    See Also:
      - `Class.getCanonicalName()`

  - ### getCanonicalName

    public static String getCanonicalName(Object object, String valueIfNull)
    Gets the canonical name for an `Object`.
    Parameters:
      `object` - the object for which to get the canonical class name; may be null
      `valueIfNull` - the return value if null
    Returns:
      the canonical name of the object or `valueIfNull`
    Since:
      3.7
    See Also:
      - `Class.getCanonicalName()`

  - ### getClass

    public static Class<?> getClass(ClassLoader classLoader, String className) throws ClassNotFoundException
    Gets the (initialized) class represented by `className` using the `classLoader`. This implementation supports the syntaxes "`java.util.Map.Entry[]`", "`java.util.Map$Entry[]`", "`[Ljava.util.Map.Entry;`", and "`[Ljava.util.Map$Entry;`".
    Parameters:
      `classLoader` - the class loader to use to load the class
      `className` - the class name
    Returns:
      the class represented by `className` using the `classLoader`
    Throws:
      `NullPointerException` - if the className is null
      `ClassNotFoundException` - if the class is not found

  - ### getClass

    public static Class<?> getClass(ClassLoader classLoader, String className, boolean initialize) throws ClassNotFoundException
    Gets the class represented by `className` using the `classLoader`. This implementation supports the syntaxes "`java.util.Map.Entry[]`", "`java.util.Map$Entry[]`", "`[Ljava.util.Map.Entry;`", and "`[Ljava.util.Map$Entry;`".
    Parameters:
      `classLoader` - the class loader to use to load the class
      `className` - the class name
      `initialize` - whether the class must be initialized
    Returns:
      the class represented by `className` using the `classLoader`
    Throws:
      `NullPointerException` - if the className is null
      `ClassNotFoundException` - if the class is not found

  - ### getClass

    public static Class<?> getClass(String className) throws ClassNotFoundException
    Gets the (initialized) class represented by `className` using the current thread's context class loader. This implementation supports the syntaxes "`java.util.Map.Entry[]`", "`java.util.Map$Entry[]`", "`[Ljava.util.Map.Entry;`", and "`[Ljava.util.Map$Entry;`".
    Parameters:
      `className` - the class name
    Returns:
      the class represented by `className` using the current thread's context class loader
    Throws:
      `NullPointerException` - if the className is null
      `ClassNotFoundException` - if the class is not found

  - ### getClass

    public static Class<?> getClass(String className, boolean initialize) throws ClassNotFoundException
    Gets the class represented by `className` using the current thread's context class loader. This implementation supports the syntaxes "`java.util.Map.Entry[]`", "`java.util.Map$Entry[]`", "`[Ljava.util.Map.Entry;`", and "`[Ljava.util.Map$Entry;`".
    Parameters:
      `className` - the class name
      `initialize` - whether the class must be initialized
    Returns:
      the class represented by `className` using the current thread's context class loader
    Throws:
      `NullPointerException` - if the className is null
      `ClassNotFoundException` - if the class is not found

  - ### getComponentType

    public static <T> Class<T> getComponentType(Class<T[]> cls)
    Delegates to `Class.getComponentType()` using generics.
    Type Parameters:
      `T` - The array class type.
    Parameters:
      `cls` - A class or null.
    Returns:
      The array component type or null.
    Since:
      3.13.0
    See Also:
      - `Class.getComponentType()`

  - ### getName

    public static String getName(Class<?> cls)
    Null-safe version of `cls.getName()`
    Parameters:
      `cls` - the class for which to get the class name; may be null
    Returns:
      the class name or the empty string in case the argument is `null`
    Since:
      3.7
    See Also:
      - `Class.getSimpleName()`

  - ### getName

    public static String getName(Class<?> cls, String valueIfNull)
    Null-safe version of `cls.getName()`
    Parameters:
      `cls` - the class for which to get the class name; may be null
      `valueIfNull` - the return value if the argument `cls` is `null`
    Returns:
      the class name or `valueIfNull`
    Since:
      3.7
    See Also:
      - `Class.getName()`

  - ### getName

    public static String getName(Object object)
    Null-safe version of `object.getClass().getName()`
    Parameters:
      `object` - the object for which to get the class name; may be null
    Returns:
      the class name or the empty String
    Since:
      3.7
    See Also:
      - `Class.getSimpleName()`

  - ### getName

    public static String getName(Object object, String valueIfNull)
    Null-safe version of `object.getClass().getSimpleName()`
    Parameters:
      `object` - the object for which to get the class name; may be null
      `valueIfNull` - the value to return if `object` is `null`
    Returns:
      the class name or `valueIfNull`
    Since:
      3.0
    See Also:
      - `Class.getName()`

  - ### getPackageCanonicalName

    public static String getPackageCanonicalName(Class<?> cls)
    Gets the package name from the canonical name of a `Class`.
    Parameters:
      `cls` - the class to get the package name for, may be `null`.
    Returns:
      the package name or an empty string
    Since:
      2.4

  - ### getPackageCanonicalName

    public static String getPackageCanonicalName(Object object, String valueIfNull)
    Gets the package name from the class name of an `Object`.
    Parameters:
      `object` - the class to get the package name for, may be null
      `valueIfNull` - the value to return if null
    Returns:
      the package name of the object, or the null value
    Since:
      2.4

  - ### getPackageCanonicalName

    public static String getPackageCanonicalName(String name)
    Gets the package name from the class name.

    The string passed in is assumed to be a class name - it is not checked.

    If the class is in the default package, return an empty string.

    Parameters:
      `name` - the name to get the package name for, may be `null`
    Returns:
      the package name or an empty string
    Since:
      2.4

  - ### getPackageName

    public static String getPackageName(Class<?> cls)
    Gets the package name of a `Class`.
    Parameters:
      `cls` - the class to get the package name for, may be `null`.
    Returns:
      the package name or an empty string

  - ### getPackageName

    public static String getPackageName(Object object, String valueIfNull)
    Gets the package name of an `Object`.
    Parameters:
      `object` - the class to get the package name for, may be null
      `valueIfNull` - the value to return if null
    Returns:
      the package name of the object, or the null value

  - ### getPackageName

    public static String getPackageName(String className)
    Gets the package name from a `String`.

    The string passed in is assumed to be a class name.

    If the class is unpackaged, return an empty string.

    Parameters:
      `className` - the className to get the package name for, may be `null`.
    Returns:
      the package name or an empty string.

  - ### getPublicMethod

    public static Method getPublicMethod(Class<?> cls, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException
    Gets the desired Method much like `Class.getMethod`, however it ensures that the returned Method is from a public class or interface and not from an anonymous inner class. This means that the Method is invokable and doesn't fall foul of Java bug (4071957).

         Set set = Collections.unmodifiableSet(...);
         Method method = ClassUtils.getPublicMethod(set.getClass(), "isEmpty",  new Class[0]);
         Object result = method.invoke(set, new Object[]);

    Parameters:
      `cls` - the class to check, not null
      `methodName` - the name of the method
      `parameterTypes` - the list of parameters
    Returns:
      the method
    Throws:
      `NullPointerException` - if the class is null
      `SecurityException` - if a security violation occurred
      `NoSuchMethodException` - if the method is not found in the given class or if the method doesn't conform with the requirements

  - ### getShortCanonicalName

    public static String getShortCanonicalName(Class<?> cls)
    Gets the canonical name minus the package name from a `Class`.
    Parameters:
      `cls` - the class for which to get the short canonical class name; may be null
    Returns:
      the canonical name without the package name or an empty string
    Since:
      2.4
    See Also:
      - `Class.getCanonicalName()`

  - ### getShortCanonicalName

    public static String getShortCanonicalName(Object object, String valueIfNull)
    Gets the canonical name minus the package name for an `Object`.
    Parameters:
      `object` - the class to get the short name for, may be null
      `valueIfNull` - the value to return if null
    Returns:
      the canonical name of the object without the package name, or the null value
    Since:
      2.4
    See Also:
      - `Class.getCanonicalName()`

  - ### getShortCanonicalName

    public static String getShortCanonicalName(String canonicalName)
    Gets the canonical name minus the package name from a String.

    The string passed in is assumed to be a class name - it is not checked.

    Note that this method is mainly designed to handle the arrays and primitives properly. If the class is an inner class then the result value will not contain the outer classes. This way the behavior of this method is different from `getShortClassName(String)`. The argument in that case is class name and not canonical name and the return value retains the outer classes.

    Note that there is no way to reliably identify the part of the string representing the package hierarchy and the part that is the outer class or classes in case of an inner class. Trying to find the class would require reflective call and the class itself may not even be on the class path. Relying on the fact that class names start with capital letter and packages with lower case is heuristic.

    It is recommended to use `getShortClassName(String)` for cases when the class is an inner class and use this method for cases it is designed for.

    Examples
    return value | input
    `""` | `(String) null`
    `"Map.Entry"` | `java.util.Map.Entry.class.getName()`
    `"Entry"` | `java.util.Map.Entry.class.getCanonicalName()`
    `"ClassUtils"` | `"org.apache.commons.lang3.ClassUtils"`
    `"ClassUtils[]"` | `"[Lorg.apache.commons.lang3.ClassUtils;"`
    `"ClassUtils[][]"` | `"[[Lorg.apache.commons.lang3.ClassUtils;"`
    `"ClassUtils[]"` | `"org.apache.commons.lang3.ClassUtils[]"`
    `"ClassUtils[][]"` | `"org.apache.commons.lang3.ClassUtils[][]"`
    `"int[]"` | `"[I"`
    `"int[]"` | `int[].class.getCanonicalName()`
    `"int[]"` | `int[].class.getName()`
    `"int[][]"` | `"[[I"`
    `"int[]"` | `"int[]"`
    `"int[][]"` | `"int[][]"`

    Parameters:
      `canonicalName` - the class name to get the short name for
    Returns:
      the canonical name of the class without the package name or an empty string
    Since:
      2.4

  - ### getShortClassName

    public static String getShortClassName(Class<?> cls)
    Gets the class name minus the package name from a `Class`.

    This method simply gets the name using `Class.getName()` and then calls `getShortClassName(String)`. See relevant notes there.

    Parameters:
      `cls` - the class to get the short name for.
    Returns:
      the class name without the package name or an empty string. If the class is an inner class then the returned value will contain the outer class or classes separated with `.` (dot) character.

  - ### getShortClassName

    public static String getShortClassName(Object object, String valueIfNull)
    Gets the class name of the `object` without the package name or names.

    The method looks up the class of the object and then converts the name of the class invoking `getShortClassName(Class)` (see relevant notes there).

    Parameters:
      `object` - the class to get the short name for, may be `null`
      `valueIfNull` - the value to return if the object is `null`
    Returns:
      the class name of the object without the package name, or `valueIfNull` if the argument `object` is `null`

  - ### getShortClassName

    public static String getShortClassName(String className)
    Gets the class name minus the package name from a String.

    The string passed in is assumed to be a class name - it is not checked. The string has to be formatted the way as the JDK method `Class.getName()` returns it, and not the usual way as we write it, for example in import statements, or as it is formatted by `Class.getCanonicalName()`.

    The difference is significant only in case of classes that are inner classes of some other classes. In this case the separator between the outer and inner class (possibly on multiple hierarchy level) has to be `$` (dollar sign) and not `.` (dot), as it is returned by `Class.getName()`

    Note that this method is called from the `getShortClassName(Class)` method using the string returned by `Class.getName()`.

    Note that this method differs from `getSimpleName(Class)` in that this will return, for example `"Map.Entry"` whilst the `Class` variant will simply return `"Entry"`. In this example the argument `className` is the string `java.util.Map$Entry` (note the `$` sign).

    Parameters:
      `className` - the className to get the short name for. It has to be formatted as returned by `Class.getName()` and not `Class.getCanonicalName()`
    Returns:
      the class name of the class without the package name or an empty string. If the class is an inner class then value contains the outer class or classes and the separator is replaced to be `.` (dot) character.

  - ### getSimpleName

    public static String getSimpleName(Class<?> cls)
    Null-safe version of `cls.getSimpleName()`
    Parameters:
      `cls` - the class for which to get the simple name; may be null
    Returns:
      the simple class name or the empty string in case the argument is `null`
    Since:
      3.0
    See Also:
      - `Class.getSimpleName()`

  - ### getSimpleName

    public static String getSimpleName(Class<?> cls, String valueIfNull)
    Null-safe version of `cls.getSimpleName()`
    Parameters:
      `cls` - the class for which to get the simple name; may be null
      `valueIfNull` - the value to return if null
    Returns:
      the simple class name or `valueIfNull` if the argument `cls` is `null`
    Since:
      3.0
    See Also:
      - `Class.getSimpleName()`

  - ### getSimpleName

    public static String getSimpleName(Object object)
    Null-safe version of `object.getClass().getSimpleName()`

    It is to note that this method is overloaded and in case the argument `object` is a `Class` object then the `getSimpleName(Class)` will be invoked. If this is a significant possibility then the caller should check this case and call `getSimpleName(Class.class)` or just simply use the string literal `"Class"`, which is the result of the method in that case.

    Parameters:
      `object` - the object for which to get the simple class name; may be null
    Returns:
      the simple class name or the empty string in case the argument is `null`
    Since:
      3.7
    See Also:
      - `Class.getSimpleName()`

  - ### getSimpleName

    public static String getSimpleName(Object object, String valueIfNull)
    Null-safe version of `object.getClass().getSimpleName()`
    Parameters:
      `object` - the object for which to get the simple class name; may be null
      `valueIfNull` - the value to return if `object` is `null`
    Returns:
      the simple class name or `valueIfNull` if the argument `object` is `null`
    Since:
      3.0
    See Also:
      - `Class.getSimpleName()`

  - ### hierarchy

    public static Iterable<Class<?>> hierarchy(Class<?> type)
    Gets an `Iterable` that can iterate over a class hierarchy in ascending (subclass to superclass) order, excluding interfaces.
    Parameters:
      `type` - the type to get the class hierarchy from
    Returns:
      Iterable an Iterable over the class hierarchy of the given class
    Since:
      3.2

  - ### hierarchy

    public static Iterable<Class<?>> hierarchy(Class<?> type, ClassUtils.Interfaces interfacesBehavior)
    Gets an `Iterable` that can iterate over a class hierarchy in ascending (subclass to superclass) order.
    Parameters:
      `type` - the type to get the class hierarchy from
      `interfacesBehavior` - switch indicating whether to include or exclude interfaces
    Returns:
      Iterable an Iterable over the class hierarchy of the given class
    Since:
      3.2

  - ### isAssignable

    public static boolean isAssignable(Class<?> cls, Class<?> toClass)
    Tests whether one `Class` can be assigned to a variable of another `Class`.

    Unlike the `Class.isAssignableFrom(java.lang.Class)` method, this method takes into account widenings of primitive classes and `null`s.

    Primitive widenings allow an int to be assigned to a long, float or double. This method returns the correct result for these cases.

    `null` may be assigned to any reference type. This method will return `true` if `null` is passed in and the toClass is non-primitive.

    Specifically, this method tests whether the type represented by the specified `Class` parameter can be converted to the type represented by this `Class` object via an identity conversion widening primitive or widening reference conversion. See The Java Language Specification, sections 5.1.1, 5.1.2 and 5.1.4 for details.

    Since Lang 3.0, this method will default behavior for calculating assignability between primitive and wrapper types corresponding to the running Java version; i.e. autoboxing will be the default behavior in VMs running Java versions > 1.5.

    Parameters:
      `cls` - the Class to check, may be null
      `toClass` - the Class to try to assign into, returns false if null
    Returns:
      `true` if assignment possible

  - ### isAssignable

    public static boolean isAssignable(Class<?> cls, Class<?> toClass, boolean autoboxing)
    Tests whether one `Class` can be assigned to a variable of another `Class`.

    Unlike the `Class.isAssignableFrom(java.lang.Class)` method, this method takes into account widenings of primitive classes and `null`s.

    Primitive widenings allow an int to be assigned to a long, float or double. This method returns the correct result for these cases.

    `null` may be assigned to any reference type. This method will return `true` if `null` is passed in and the toClass is non-primitive.

    Specifically, this method tests whether the type represented by the specified `Class` parameter can be converted to the type represented by this `Class` object via an identity conversion widening primitive or widening reference conversion. See The Java Language Specification, sections 5.1.1, 5.1.2 and 5.1.4 for details.

    Parameters:
      `cls` - the Class to check, may be null
      `toClass` - the Class to try to assign into, returns false if null
      `autoboxing` - whether to use implicit autoboxing/unboxing between primitives and wrappers
    Returns:
      `true` if assignment possible

  - ### isAssignable

    public static boolean isAssignable(Class<?>[] classArray, Class<?>... toClassArray)
    Tests whether an array of Classes can be assigned to another array of Classes.

    This method calls `isAssignable` for each Class pair in the input arrays. It can be used to check if a set of arguments (the first parameter) are suitably compatible with a set of method parameter types (the second parameter).

    Unlike the `Class.isAssignableFrom(java.lang.Class)` method, this method takes into account widenings of primitive classes and `null`s.

    Primitive widenings allow an int to be assigned to a `long`, `float` or `double`. This method returns the correct result for these cases.

    `null` may be assigned to any reference type. This method will return `true` if `null` is passed in and the toClass is non-primitive.

    Specifically, this method tests whether the type represented by the specified `Class` parameter can be converted to the type represented by this `Class` object via an identity conversion widening primitive or widening reference conversion. See The Java Language Specification, sections 5.1.1, 5.1.2 and 5.1.4 for details.

    Since Lang 3.0, this method will default behavior for calculating assignability between primitive and wrapper types corresponding to the running Java version; i.e. autoboxing will be the default behavior in VMs running Java versions > 1.5.

    Parameters:
      `classArray` - the array of Classes to check, may be `null`
      `toClassArray` - the array of Classes to try to assign into, may be `null`
    Returns:
      `true` if assignment possible

  - ### isAssignable

    public static boolean isAssignable(Class<?>[] classArray, Class<?>[] toClassArray, boolean autoboxing)
    Tests whether an array of Classes can be assigned to another array of Classes.

    This method calls `isAssignable` for each Class pair in the input arrays. It can be used to check if a set of arguments (the first parameter) are suitably compatible with a set of method parameter types (the second parameter).

    Unlike the `Class.isAssignableFrom(java.lang.Class)` method, this method takes into account widenings of primitive classes and `null`s.

    Primitive widenings allow an int to be assigned to a `long`, `float` or `double`. This method returns the correct result for these cases.

    `null` may be assigned to any reference type. This method will return `true` if `null` is passed in and the toClass is non-primitive.

    Specifically, this method tests whether the type represented by the specified `Class` parameter can be converted to the type represented by this `Class` object via an identity conversion widening primitive or widening reference conversion. See The Java Language Specification, sections 5.1.1, 5.1.2 and 5.1.4 for details.

    Parameters:
      `classArray` - the array of Classes to check, may be `null`
      `toClassArray` - the array of Classes to try to assign into, may be `null`
      `autoboxing` - whether to use implicit autoboxing/unboxing between primitives and wrappers
    Returns:
      `true` if assignment possible

  - ### isInnerClass

    public static boolean isInnerClass(Class<?> cls)
    Tests whether the specified class an inner class or static nested class.
    Parameters:
      `cls` - the class to check, may be null
    Returns:
      `true` if the class is an inner or static nested class, false if not or `null`

  - ### isPrimitiveOrWrapper

    public static boolean isPrimitiveOrWrapper(Class<?> type)
    Tests whether the given `type` is a primitive or primitive wrapper (`Boolean`, `Byte`, `Character`, `Short`, `Integer`, `Long`, `Double`, `Float`).
    Parameters:
      `type` - The class to query or null.
    Returns:
      true if the given `type` is a primitive or primitive wrapper (`Boolean`, `Byte`, `Character`, `Short`, `Integer`, `Long`, `Double`, `Float`).
    Since:
      3.1

  - ### isPrimitiveWrapper

    public static boolean isPrimitiveWrapper(Class<?> type)
    Tests whether the given `type` is a primitive wrapper (`Boolean`, `Byte`, `Character`, `Short`, `Integer`, `Long`, `Double`, `Float`).
    Parameters:
      `type` - The class to query or null.
    Returns:
      true if the given `type` is a primitive wrapper (`Boolean`, `Byte`, `Character`, `Short`, `Integer`, `Long`, `Double`, `Float`).
    Since:
      3.1

  - ### isPublic

    public static boolean isPublic(Class<?> cls)
    Tests whether a `Class` is public.
    Parameters:
      `cls` - Class to test.
    Returns:
      `true` if `cls` is public.
    Since:
      3.13.0

  - ### primitivesToWrappers

    public static Class<?>[] primitivesToWrappers(Class<?>... classes)
    Converts the specified array of primitive Class objects to an array of its corresponding wrapper Class objects.
    Parameters:
      `classes` - the class array to convert, may be null or empty.
    Returns:
      an array which contains for each given class, the wrapper class or the original class if class is not a primitive. `null` if null input. Empty array if an empty array passed in.
    Since:
      2.1

  - ### primitiveToWrapper

    public static Class<?> primitiveToWrapper(Class<?> cls)
    Converts the specified primitive Class object to its corresponding wrapper Class object.

    NOTE: From v2.2, this method handles `Void.TYPE`, returning `Void.TYPE`.

    Parameters:
      `cls` - the class to convert, may be null.
    Returns:
      the wrapper class for `cls` or `cls` if `cls` is not a primitive. `null` if null input.
    Since:
      2.1

  - ### toClass

    public static Class<?>[] toClass(Object... array)
    Converts an array of `Object` in to an array of `Class` objects. If any of these objects is null, a null element will be inserted into the array.

    This method returns `null` for a `null` input array.

    Parameters:
      `array` - an `Object` array
    Returns:
      a `Class` array, `null` if null array input
    Since:
      2.4

  - ### wrappersToPrimitives

    public static Class<?>[] wrappersToPrimitives(Class<?>... classes)
    Converts the specified array of wrapper Class objects to an array of its corresponding primitive Class objects.

    This method invokes `wrapperToPrimitive()` for each element of the passed in array.

    Parameters:
      `classes` - the class array to convert, may be null or empty
    Returns:
      an array which contains for each given class, the primitive class or null if the original class is not a wrapper class. `null` if null input. Empty array if an empty array passed in.
    Since:
      2.4
    See Also:
      - `wrapperToPrimitive(Class)`

  - ### wrapperToPrimitive

    public static Class<?> wrapperToPrimitive(Class<?> cls)
    Converts the specified wrapper class to its corresponding primitive class.

    This method is the counter part of `primitiveToWrapper()`. If the passed in class is a wrapper class for a primitive type, this primitive type will be returned (e.g. `Integer.TYPE` for `Integer.class`). For other classes, or if the parameter is null, the return value is null.

    Parameters:
      `cls` - the class to convert, may be null
    Returns:
      the corresponding primitive type if `cls` is a wrapper class, null otherwise
    Since:
      2.4
    See Also:
      - `primitiveToWrapper(Class)`