@Immutable public final class ClassHelper extends Object
Class helper methods.| Modifier and Type | Method and Description |
|---|---|
static boolean |
areConvertibleClasses(Class<?> aSrcClass,
Class<?> aDstClass)
Check if the passed classes are convertible.
|
static Set<Class<?>> |
getAllPrimitiveClasses() |
static Set<Class<?>> |
getAllPrimitiveWrapperClasses() |
static Class<?> |
getClass(Object aObject)
null-safe helper method to determine the class of an object. |
static String |
getClassFromPath(String sPath)
Get the class name of the passed path.
|
static String |
getClassLocalName(Class<?> aClass)
Get the name of the class without the package.
|
static String |
getClassLocalName(Object aObject)
Get the name of the object's class without the package.
|
static String |
getClassLocalName(String sClassName)
Get the name of the class without the package.
|
static String |
getClassName(Object aObject)
null-safe helper method to determine the class name of an
object. |
static String |
getClassPackageName(Class<?> aClass)
Get the name of the package the passed class resides in.
|
static String |
getClassPackageName(Object aObject)
Get the name of the package the passed object resides in.
|
static String |
getClassPackageName(String sClassName)
Get the name of the package the passed class resides in.
|
static String |
getDirectoryFromPackage(Package aPackage)
Convert a package name to a relative directory name.
|
static String |
getDirectoryFromPackage(String sPackage)
Convert a package name to a relative directory name.
|
static String |
getObjectAddress(Object aObject)
Get the hex representation of the passed object's address.
|
static String |
getPathFromClass(Class<?> aClass)
Get the path representation of the passed class.
|
static String |
getPathFromClass(String sClassName)
Get the path representation of the passed class name.
|
static Class<?> |
getPrimitiveClass(Class<?> aClass)
Get the primitive class of the passed primitive wrapper class.
|
static Class<?> |
getPrimitiveWrapperClass(Class<?> aClass)
Get the primitive wrapper class of the passed primitive class.
|
static String |
getSafeClassName(Object aObject)
Get the class name of the passed object.
|
static boolean |
isAbstractClass(Class<?> aClass)
Check if the passed class is abstract or not.
|
static boolean |
isAnnotationClass(Class<?> aClass) |
static boolean |
isArrayClass(Class<?> aClass) |
static boolean |
isBooleanClass(Class<?> aClass) |
static boolean |
isCharacterClass(Class<?> aClass) |
static boolean |
isEnumClass(Class<?> aClass) |
static boolean |
isFloatingPointClass(Class<?> aClass) |
static boolean |
isInstancableClass(Class<?> aClass)
Check if the passed class is public, instancable and has a no-argument
constructor.
|
static boolean |
isIntegerClass(Class<?> aClass) |
static boolean |
isInterface(Class<?> aClass)
Check if the passed class is an interface or not.
|
static boolean |
isPrimitiveType(Class<?> aClass) |
static boolean |
isPrimitiveWrapperType(Class<?> aClass) |
static boolean |
isPublic(Class<?> aClass) |
static boolean |
isPublicClass(Class<?> aClass) |
static boolean |
isStringClass(Class<?> aClass) |
public static boolean isInstancableClass(@Nullable Class<?> aClass)
aClass - The class to check. May be null.true if the class is public, instancable and has a
no-argument constructor that is public.public static boolean isInterface(@Nullable Class<?> aClass)
aClass - The class to check.true if the class is an interface (or an annotation)public static boolean isAbstractClass(@Nullable Class<?> aClass)
aClass - The class to check.true if the passed class is abstract@Nullable public static Class<?> getPrimitiveWrapperClass(@Nullable Class<?> aClass)
aClass - The primitive class. May be null.null if the passed class is not a primitive class.@Nullable public static Class<?> getPrimitiveClass(@Nullable Class<?> aClass)
aClass - The primitive wrapper class. May be null.null if the passed class is not a primitive wrapper
class.@Nonnull @ReturnsMutableCopy public static Set<Class<?>> getAllPrimitiveClasses()
@Nonnull @ReturnsMutableCopy public static Set<Class<?>> getAllPrimitiveWrapperClasses()
public static boolean areConvertibleClasses(@Nonnull Class<?> aSrcClass, @Nonnull Class<?> aDstClass)
aSrcClass - First class. May not be null.aDstClass - Second class. May not be null.true if the classes are directly convertible.@Nullable public static Class<?> getClass(@Nullable Object aObject)
null-safe helper method to determine the class of an object.aObject - The object to query. May be null.null if the passed object is null.@Nullable public static String getClassName(@Nullable Object aObject)
null-safe helper method to determine the class name of an
object.aObject - The object to query. May be null.null if the passed object is null.@Nullable public static String getClassLocalName(@Nullable Object aObject)
aObject - The object to get the information from. May be null .@Nullable public static String getClassLocalName(@Nullable Class<?> aClass)
aClass - The class to get the information from. May be null.@Nullable public static String getClassLocalName(@Nullable String sClassName)
sClassName - The fully qualified name of the class. May be null.null.@Nullable public static String getClassPackageName(@Nullable Object aObject)
aObject - The class to get the information from. May be null.@Nullable public static String getClassPackageName(@Nullable Class<?> aClass)
aClass - The class to get the information from. May not be null.@Nullable public static String getClassPackageName(@Nullable String sClassName)
sClassName - The name class to get the information from. May be null
.@Nonnull @Nonempty public static String getSafeClassName(@Nullable Object aObject)
Class, its name is retrieved, other Object.getClass() is called.aObject - The object who's class name is to be retrieved."null" for a null parameter@Nullable public static String getDirectoryFromPackage(@Nullable Package aPackage)
aPackage - The package to be converted. May be null.@Nullable public static String getDirectoryFromPackage(@Nullable String sPackage)
sPackage - The name of the package to be converted. May be null.@Nullable public static String getPathFromClass(@Nullable Class<?> aClass)
aClass - The class of which the path is to be retrieved. May be
null.null.@Nullable public static String getPathFromClass(@Nullable String sClassName)
sClassName - The class name of which the path is to be retrieved. May be
null.@Nullable public static String getClassFromPath(@Nullable String sPath)
sPath - The path to be converted. May be null.@Nonnull @Nonempty public static String getObjectAddress(@Nullable Object aObject)
aObject - The object who's address is to be retrieved. May be
null.System.identityHashCode(Object)Copyright © 2014–2015 Philip Helger. All rights reserved.