Class ClassUtil
java.lang.Object
org.codehaus.jackson.map.util.ClassUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcanBeABeanType(Class<?> type) static voidcheckAndFixAccess(Member member) Method called to check if we can use the passed method or constructor (wrt access restriction -- public methods can be called, others usually not); and if not, if there is a work-around for the problem.static <T> TcreateInstance(Class<T> cls, boolean canFixAccess) Method that can be called to try to create an instantiate of specified type.static ObjectdefaultValue(Class<?> cls) Helper method used to get default value for wrappers used for primitive types (0 for Integer etc)static Class<?> static <T> Constructor<T> findConstructor(Class<T> cls, boolean canFixAccess) findEnumType(Class<?> cls) Helper method that can be used to dynamically figure out formal enumeration type (class) for given class of an enumeration value.findEnumType(Enum<?> en) Helper method that can be used to dynamically figure out formal enumeration type (class) for given enumeration.findEnumType(EnumMap<?, ?> m) Helper method that can be used to dynamically figure out enumeration type of givenEnumSet, without having access to its declaration.findEnumType(EnumSet<?> s) Helper method that can be used to dynamically figure out enumeration type of givenEnumSet, without having access to its declaration.findSuperTypes(Class<?> cls, Class<?> endBefore) Method that will find all sub-classes and implemented interfaces of a given class or interface.findSuperTypes(Class<?> cls, Class<?> endBefore, List<Class<?>> result) static StringgetClassDescription(Object classOrInstance) Helper method used to construct appropriate description when passed either type (Class) or an instance; in latter case, class of instance is to be used.static Class<?> getOuterClass(Class<?> type) Method for finding enclosing class for non-static inner classesstatic ThrowableMethod that can be used to find the "root cause", innermost of chained (wrapped) exceptions.static booleanstatic booleanisCollectionMapOrArray(Class<?> type) static booleanisConcrete(Class<?> type) Helper method that checks if given class is a concrete one; that is, not an interface or abstract class.static booleanisConcrete(Member member) static StringisLocalType(Class<?> type) Deprecated.since 1.9, use variant that takes second argumentstatic StringisLocalType(Class<?> type, boolean allowNonStatic) static booleanisProxyType(Class<?> type) Helper method used to weed out dynamic Proxy types; types that do not expose concrete method API that we could use to figure out automatic Bean (property) based serialization.static voidMethod that will wrap 't' as anIllegalArgumentExceptionif it is a checked exception; otherwise (runtime exception or error) throw as isstatic voidthrowAsIAE(Throwable t, String msg) Method that will wrap 't' as anIllegalArgumentException(and with specified message) if it is a checked exception; otherwise (runtime exception or error) throw as isstatic voidstatic voidMethod that will locate the innermost exception for given Throwable; and then wrap it as anIllegalArgumentExceptionif it is a checked exception; otherwise (runtime exception or error) throw as isstatic voidunwrapAndThrowAsIAE(Throwable t, String msg) Method that will locate the innermost exception for given Throwable; and then wrap it as anIllegalArgumentExceptionif it is a checked exception; otherwise (runtime exception or error) throw as isstatic Class<?> wrapperType(Class<?> primitiveType) Helper method for finding wrapper type for given primitive type (why isn't there one in JDK?)
-
Constructor Details
-
ClassUtil
public ClassUtil()
-
-
Method Details
-
findSuperTypes
Method that will find all sub-classes and implemented interfaces of a given class or interface. Classes are listed in order of precedence, starting with the immediate super-class, followed by interfaces class directly declares to implemented, and then recursively followed by parent of super-class and so forth. Note thatObject.classis not included in the list regardless of whetherendBeforeargument is defined or not.- Parameters:
endBefore- Super-type to NOT include in results, if any; when encountered, will be ignored (and no super types are checked).
-
findSuperTypes
-
canBeABeanType
-
isLocalType
Deprecated.since 1.9, use variant that takes second argument -
isLocalType
-
getOuterClass
-
isProxyType
Helper method used to weed out dynamic Proxy types; types that do not expose concrete method API that we could use to figure out automatic Bean (property) based serialization. -
isConcrete
Helper method that checks if given class is a concrete one; that is, not an interface or abstract class. -
isConcrete
- Since:
- 1.6
-
isCollectionMapOrArray
-
getClassDescription
-
findClass
- Throws:
ClassNotFoundException
-
hasGetterSignature
-
getRootCause
-
throwRootCause
-
throwAsIAE
Method that will wrap 't' as anIllegalArgumentExceptionif it is a checked exception; otherwise (runtime exception or error) throw as is -
throwAsIAE
Method that will wrap 't' as anIllegalArgumentException(and with specified message) if it is a checked exception; otherwise (runtime exception or error) throw as is -
unwrapAndThrowAsIAE
Method that will locate the innermost exception for given Throwable; and then wrap it as anIllegalArgumentExceptionif it is a checked exception; otherwise (runtime exception or error) throw as is -
unwrapAndThrowAsIAE
Method that will locate the innermost exception for given Throwable; and then wrap it as anIllegalArgumentExceptionif it is a checked exception; otherwise (runtime exception or error) throw as is -
createInstance
public static <T> T createInstance(Class<T> cls, boolean canFixAccess) throws IllegalArgumentException Method that can be called to try to create an instantiate of specified type. Instantiation is done using default no-argument constructor.- Parameters:
canFixAccess- Whether it is possible to try to change access rights of the default constructor (in case it is not publicly accessible) or not.- Throws:
IllegalArgumentException- If instantiation fails for any reason; except for cases where constructor throws an unchecked exception (which will be passed as is)
-
findConstructor
public static <T> Constructor<T> findConstructor(Class<T> cls, boolean canFixAccess) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
defaultValue
-
wrapperType
-
checkAndFixAccess
Method called to check if we can use the passed method or constructor (wrt access restriction -- public methods can be called, others usually not); and if not, if there is a work-around for the problem. -
findEnumType
-
findEnumType
-
findEnumType
Helper method that can be used to dynamically figure out formal enumeration type (class) for given enumeration. This is either class of enum instance (for "simple" enumerations), or its superclass (for enums with instance fields or methods) -
findEnumType
Helper method that can be used to dynamically figure out formal enumeration type (class) for given class of an enumeration value. This is either class of enum instance (for "simple" enumerations), or its superclass (for enums with instance fields or methods)
-