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.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | ClassUtils.
Inclusivity literals for |
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | ABBREVIATION_MAP
Maps a primitive class name to its corresponding abbreviation used in array class names. |
| private static final Comparator | |
| public static final String | INNER_CLASS_SEPARATOR
The inner class separator String: |
| public static final char | INNER_CLASS_SEPARATOR_CHAR
The inner class separator character: |
| private static final int | MAX_DIMENSIONS
The maximum number of array dimensions. |
| private static final Map | NAME_PRIMITIVE_MAP
Maps names of primitives to their corresponding primitive |
| public static final String | PACKAGE_SEPARATOR
The package separator String: |
| public static final char | PACKAGE_SEPARATOR_CHAR
The package separator character: |
| private static final Map | PRIMITIVE_WRAPPER_MAP
Maps primitive |
| private static final Map | REVERSE_ABBREVIATION_MAP
Maps an abbreviation used in array class names to corresponding primitive class name. |
| private static final Map | WRAPPER_PRIMITIVE_MAP
Maps wrapper |
| Access | Constructor and Description |
|---|---|
| public | ClassUtils()
Deprecated
TODO Make private in 4.0.
ClassUtils instances should NOT be constructed in standard programming. |
| Modifier and Type | Method and Description |
|---|---|
| public static Comparator | |
| public static List | |
| public static List | convertClassNamesToClasses(final List<String>
the classNames to change classNames)Given a |
| public static String | Returns: the abbreviated name or an empty stringthe class to get the abbreviated name for, may be cls, final int nullthe desired length of the abbreviated name lengthHint)Gets the abbreviated name of a |
| public static String | Returns: the abbreviated name or an empty string if the specified class name isnull or empty string. The
abbreviated name may be longer than the desired length if it cannot be abbreviated to the desired length.the className to get the abbreviated name for, may be className, final int nullthe desired length of the abbreviated name lengthHint)Gets the abbreviated class name from a |
| public static List | getAllInterfaces(final Class<?>
the class to look up, may be cls)nullGets a |
| private static void | getAllInterfaces(Class<?>
the class to look up, may be cls, final HashSet<Class<?>> nullthe interfacesFound)Set of interfaces for the classGets the interfaces for the specified class. |
| public static List | getAllSuperclasses(final Class<?>
the class to look up, may be cls)nullGets a |
| public static String | Returns: the canonical name of the class, or the empty Stringthe class for which to get the canonical class name; may be null cls)Gets the canonical class name for a |
| public static String | Returns: the canonical name of the class, orvalueIfNullthe class for which to get the canonical class name; may be null cls, final String the return value if null valueIfNull)Gets the canonical name for a |
| public static String | Returns: the canonical name of the object, or the empty Stringthe object for which to get the canonical class name; may be null object)Gets the canonical name for an |
| public static String | Returns: the canonical name of the object orvalueIfNullthe object for which to get the canonical class name; may be null object, final String the return value if null valueIfNull)Gets the canonical name for an |
| private static String | Returns: canonical form of class name.the name of class. name)Converts a given name of class into canonical format. |
| public static Class | Returns: the class represented byclassName using the classLoaderthe class loader to use to load the class classLoader, final String the class name className)Gets the (initialized) class represented by |
| public static Class | Returns: the class represented byclassName using the classLoaderthe class loader to use to load the class classLoader, final String the class name className, final boolean whether the class must be initialized initialize)Gets the class represented by |
| public static Class | |
| public static Class | |
| public static < The array class type. T> Class | Returns: The array component type or null.A class or null. cls)Delegates to |
| public static String | |
| public static String | |
| pack-priv static String | |
| public static String | |
| public static String | |
| public static String | Returns: the package name or an empty stringthe class to get the package name for, may be cls)null.Gets the package name from the canonical name of a |
| public static String | Returns: the package name of the object, or the null valuethe class to get the package name for, may be null object, final String the value to return if null valueIfNull)Gets the package name from the class name of an |
| public static String | Returns: the package name or an empty stringthe name to get the package name for, may be name)nullGets the package name from the class name. |
| public static String | Returns: the package name or an empty stringthe class to get the package name for, may be cls)null.Gets the package name of a |
| public static String | Returns: the package name of the object, or the null valuethe class to get the package name for, may be null object, final String the value to return if null valueIfNull)Gets the package name of an |
| public static String | Returns: the package name or an empty string.the className to get the package name for, may be className)null.Gets the package name from a |
| pack-priv static Class | Returns: the primitive class.the primitive class for the given class name. className)Gets the primitive class for the given class name, for example "byte". |
| public static Method | Returns: the methodthe class to check, not null cls, final String the name of the method methodName, final Class<?>... the list of parameters parameterTypes)Gets the desired Method much like |
| public static String | Returns: the canonical name without the package name or an empty stringthe class for which to get the short canonical class name; may be null cls)Gets the canonical name minus the package name from a |
| public static String | Returns: the canonical name of the object without the package name, or the null valuethe class to get the short name for, may be null object, final String the value to return if null valueIfNull)Gets the canonical name minus the package name for an |
| public static String | Returns: the canonical name of the class without the package name or an empty stringthe class name to get the short name for canonicalName)Gets the canonical name minus the package name from a String. |
| public static String | 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.the class to get the short name for. cls)Gets the class name minus the package name from a |
| public static String | Returns: the class name of the object without the package name, orvalueIfNull if the argument object
is nullthe class to get the short name for, may be object, final String nullthe value to return if the object is valueIfNull)nullGets the class name of the |
| public static String | 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.the className to get the short name for. It has to be formatted as returned by
className)Class.getName() and not Class.getCanonicalName()Gets the class name minus the package name from a String. |
| public static String | Returns: the simple class name or the empty string in case the argument isnullthe class for which to get the simple name; may be null cls)Null-safe version of |
| public static String | Returns: the simple class name orvalueIfNull if the argument cls is nullthe class for which to get the simple name; may be null cls, final String the value to return if null valueIfNull)Null-safe version of |
| public static String | Returns: the simple class name or the empty string in case the argument isnullthe object for which to get the simple class name; may be null object)Null-safe version of
It is to note that this method is overloaded and in case the argument |
| public static String | Returns: the simple class name orvalueIfNull if the argument object is nullthe object for which to get the simple class name; may be null object, final String the value to return if valueIfNull)object is nullNull-safe version of |
| public static Iterable | |
| public static Iterable | Returns: Iterable an Iterable over the class hierarchy of the given classthe type to get the class hierarchy from type, final ClassUtils.switch indicating whether to include or exclude interfaces interfacesBehaviorGets an |
| public static boolean | Returns: true if assignment possiblethe Class to check, may be null cls, final Class<?> the Class to try to assign into, returns false if null toClass)Tests whether one |
| public static boolean | Returns: true if assignment possiblethe Class to check, may be null cls, final Class<?> the Class to try to assign into, returns false if null toClass, final boolean whether to use implicit autoboxing/unboxing between primitives and wrappers autoboxing)Tests whether one |
| public static boolean | Returns: true if assignment possiblethe array of Classes to check, may be classArray, final Class<?>... nullthe array of Classes to try to assign into, may be toClassArray)nullTests whether an array of Classes can be assigned to another array of Classes. |
| public static boolean | Returns: true if assignment possiblethe array of Classes to check, may be classArray, Class<?>[] nullthe array of Classes to try to assign into, may be toClassArray, final boolean nullwhether to use implicit autoboxing/unboxing between primitives and wrappers autoboxing)Tests whether an array of Classes can be assigned to another array of Classes. |
| public static boolean | Returns: true if the class is an inner or static nested class, false if not or nullthe class to check, may be null cls)Tests whether the specified class an inner class or static nested class. |
| public static boolean | |
| public static boolean | |
| public static boolean | |
| public static Class | 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.the class array to convert, may be null or empty. classes)Converts the specified array of primitive Class objects to an array of its corresponding wrapper Class objects. |
| public static Class | Returns: the wrapper class forcls or cls if cls is not a primitive. null if null input.the class to convert, may be null. cls)Converts the specified primitive Class object to its corresponding wrapper Class object. |
| private static String | Returns: the converted namethe class name className)Converts a class name to a JLS style class name. |
| public static Class | |
| private static boolean | Returns: true if it can be kept in its original length false if the current part has to be abbreviated
andthe target index (where the characters were copied to) pointing after the last character copied
when the current part was copied runAheadTarget, final int the source index (where the characters were copied from) pointing after the last character copied when
the current part was copied source, final int the original length of the class full name, which is abbreviated originalLength, final int the desired length of the abbreviated class name desiredLength)Decides if the part that was just copied to its destination location in the work array can be kept as it was copied or must be abbreviated. |
| public static Class | 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.the class array to convert, may be null or empty classes)Converts the specified array of wrapper Class objects to an array of its corresponding primitive Class objects. |
| public static Class | Returns: the corresponding primitive type ifcls is a wrapper class, null otherwisethe class to convert, may be null cls)Converts the specified wrapper class to its corresponding primitive class. |