Package snap.util
Class ClassUtils
java.lang.Object
snap.util.ClassUtils
Utility methods for Class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
cloneCloneable
(Cloneable anObj) Returns a clone of given Cloneable object using reflection.static Class<?>
fromPrimitive
(Class<?> aClass) Returns non-primitive type for primitive.static Class<?>
Returns the class for an object.static String
getClassCodingForClass
(Class<?> aClass) Returns a class coding for given class.static Class<?>
getClassForClassCoding
(String aName, ClassLoader aClassLoader) Returns a class for given class coding.static Class<?>
getClassForName
(String aName, ClassLoader aClassLoader) Returns a class for a given name, using the class loader of the given class.static Class<?>
getCommonClass
(Object anObj1, Object anObj2) Returns the common ancestor class for two objects.static Class<?>
getCommonClass
(List<?> aList) Returns the common ancestor class for a list of objects.static Field
getFieldForName
(Class<?> aClass, String aName) Returns a field for a parent class and a name.static <T> T
getInstance
(Object anObj, Class<T> aClass) Returns the given object as instance of given class, if it is.static Method
Class.getMethod wrapper to isolate call to one place.static Method
getMethodOrThrow
(Class<?> aClass, String aName, Class<?>... theClasses) Class.getMethod wrapper to isolate call to one place.static Class<?>
getPrimitiveClassForName
(String aName) Returns a primitive class for name.static boolean
isPrimitiveClassName
(String aName) Returns whether name is a primitive class name.static <T> T
newInstance
(Class<T> aClass) Returns a new instance of a given class.static Class<?>
toPrimitive
(Class<?> aClass) Returns primitive type for non-primitive.
-
Constructor Details
-
ClassUtils
public ClassUtils()
-
-
Method Details
-
getInstance
Returns the given object as instance of given class, if it is. -
newInstance
Returns a new instance of a given class. -
cloneCloneable
Returns a clone of given Cloneable object using reflection. -
getClass
Returns the class for an object. -
getClassForName
Returns a class for a given name, using the class loader of the given class. -
getFieldForName
Returns a field for a parent class and a name. -
getMethod
Class.getMethod wrapper to isolate call to one place. -
getMethodOrThrow
public static Method getMethodOrThrow(Class<?> aClass, String aName, Class<?>... theClasses) throws NoSuchMethodException Class.getMethod wrapper to isolate call to one place.- Throws:
NoSuchMethodException
-
isPrimitiveClassName
Returns whether name is a primitive class name. -
getPrimitiveClassForName
Returns a primitive class for name. -
toPrimitive
Returns primitive type for non-primitive. -
fromPrimitive
Returns non-primitive type for primitive. -
getClassForClassCoding
Returns a class for given class coding. -
getClassCodingForClass
Returns a class coding for given class. -
getCommonClass
Returns the common ancestor class for a list of objects. -
getCommonClass
Returns the common ancestor class for two objects.
-