|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasterxml.jackson.databind.util.ClassUtil
public final class ClassUtil
Constructor Summary | |
---|---|
ClassUtil()
|
Method Summary | ||
---|---|---|
static String |
canBeABeanType(Class<?> type)
|
|
static void |
checkAndFixAccess(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
|
createInstance(Class<T> cls,
boolean canFixAccess)
Method that can be called to try to create an instantiate of specified type. |
|
static Object |
defaultValue(Class<?> cls)
Helper method used to get default value for wrappers used for primitive types (0 for Integer etc) |
|
static Class<?> |
findClass(String className)
|
|
static
|
findConstructor(Class<T> cls,
boolean canFixAccess)
|
|
static Class<? extends Enum<?>> |
findEnumType(Class<?> cls)
Helper method that can be used to dynamically figure out formal enumeration type (class) for given class of an enumeration value. |
|
static Class<? extends Enum<?>> |
findEnumType(Enum<?> en)
Helper method that can be used to dynamically figure out formal enumeration type (class) for given enumeration. |
|
static Class<? extends Enum<?>> |
findEnumType(EnumMap<?,?> m)
Helper method that can be used to dynamically figure out enumeration type of given EnumSet , without having
access to its declaration. |
|
static Class<? extends Enum<?>> |
findEnumType(EnumSet<?> s)
Helper method that can be used to dynamically figure out enumeration type of given EnumSet , without having
access to its declaration. |
|
static List<Class<?>> |
findSuperTypes(Class<?> cls,
Class<?> endBefore)
Method that will find all sub-classes and implemented interfaces of a given class or interface. |
|
static List<Class<?>> |
findSuperTypes(Class<?> cls,
Class<?> endBefore,
List<Class<?>> result)
|
|
static String |
getClassDescription(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 classes |
|
static Throwable |
getRootCause(Throwable t)
Method that can be used to find the "root cause", innermost of chained (wrapped) exceptions. |
|
static boolean |
hasGetterSignature(Method m)
|
|
static boolean |
isCollectionMapOrArray(Class<?> type)
|
|
static boolean |
isConcrete(Class<?> type)
Helper method that checks if given class is a concrete one; that is, not an interface or abstract class. |
|
static boolean |
isConcrete(Member member)
|
|
static boolean |
isJacksonStdImpl(Class<?> implClass)
|
|
static boolean |
isJacksonStdImpl(Object impl)
Method that can be called to determine if given Object is the default implementation Jackson uses; as opposed to a custom serializer installed by a module or calling application. |
|
static String |
isLocalType(Class<?> type,
boolean allowNonStatic)
|
|
static boolean |
isProxyType(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 void |
throwAsIAE(Throwable t)
Method that will wrap 't' as an IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is |
|
static void |
throwAsIAE(Throwable t,
String msg)
Method that will wrap 't' as an IllegalArgumentException (and with
specified message) if it
is a checked exception; otherwise (runtime exception or error) throw as is |
|
static void |
throwRootCause(Throwable t)
Method that will unwrap root causes of given Throwable, and throw the innermost Exception or Error as is. |
|
static void |
unwrapAndThrowAsIAE(Throwable t)
Method that will locate the innermost exception for given Throwable; and then wrap it as an IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is |
|
static void |
unwrapAndThrowAsIAE(Throwable t,
String msg)
Method that will locate the innermost exception for given Throwable; and then wrap it as an IllegalArgumentException if it
is a checked exception; otherwise (runtime exception or error) throw as is |
|
static Class<?> |
wrapperType(Class<?> primitiveType)
Helper method for finding wrapper type for given primitive type (why isn't there one in JDK?) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassUtil()
Method Detail |
---|
public static List<Class<?>> findSuperTypes(Class<?> cls, Class<?> endBefore)
Object.class
is not included in the list
regardless of whether endBefore
argument is defined or not.
endBefore
- Super-type to NOT include in results, if any; when
encountered, will be ignored (and no super types are checked).public static List<Class<?>> findSuperTypes(Class<?> cls, Class<?> endBefore, List<Class<?>> result)
public static String canBeABeanType(Class<?> type)
public static String isLocalType(Class<?> type, boolean allowNonStatic)
public static Class<?> getOuterClass(Class<?> type)
public static boolean isProxyType(Class<?> type)
public static boolean isConcrete(Class<?> type)
public static boolean isConcrete(Member member)
public static boolean isCollectionMapOrArray(Class<?> type)
public static String getClassDescription(Object classOrInstance)
public static Class<?> findClass(String className) throws ClassNotFoundException
ClassNotFoundException
public static boolean hasGetterSignature(Method m)
public static Throwable getRootCause(Throwable t)
public static void throwRootCause(Throwable t) throws Exception
Exception
or Error
as is.
This is useful in cases where mandatory wrapping is added, which
is often done by Reflection API.
Exception
public static void throwAsIAE(Throwable t)
IllegalArgumentException
if it
is a checked exception; otherwise (runtime exception or error) throw as is
public static void throwAsIAE(Throwable t, String msg)
IllegalArgumentException
(and with
specified message) if it
is a checked exception; otherwise (runtime exception or error) throw as is
public static void unwrapAndThrowAsIAE(Throwable t)
IllegalArgumentException
if it
is a checked exception; otherwise (runtime exception or error) throw as is
public static void unwrapAndThrowAsIAE(Throwable t, String msg)
IllegalArgumentException
if it
is a checked exception; otherwise (runtime exception or error) throw as is
public static <T> T createInstance(Class<T> cls, boolean canFixAccess) throws IllegalArgumentException
canFixAccess
- Whether it is possible to try to change access
rights of the default constructor (in case it is not publicly
accessible) or not.
IllegalArgumentException
- If instantiation fails for any reason;
except for cases where constructor throws an unchecked exception
(which will be passed as is)public static <T> Constructor<T> findConstructor(Class<T> cls, boolean canFixAccess) throws IllegalArgumentException
IllegalArgumentException
public static Object defaultValue(Class<?> cls)
public static Class<?> wrapperType(Class<?> primitiveType)
public static void checkAndFixAccess(Member member)
public static Class<? extends Enum<?>> findEnumType(EnumSet<?> s)
EnumSet
, without having
access to its declaration.
Code is needed to work around design flaw in JDK.
public static Class<? extends Enum<?>> findEnumType(EnumMap<?,?> m)
EnumSet
, without having
access to its declaration.
Code is needed to work around design flaw in JDK.
public static Class<? extends Enum<?>> findEnumType(Enum<?> en)
public static Class<? extends Enum<?>> findEnumType(Class<?> cls)
public static boolean isJacksonStdImpl(Object impl)
JacksonStdImpl
annotation on handler (serializer, deserializer etc)
class.
public static boolean isJacksonStdImpl(Class<?> implClass)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |