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 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 <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 <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. -
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
-
toPrimitive
Returns primitive type for non-primitive. -
fromPrimitive
Returns non-primitive type for primitive. -
getCommonClass
Returns the common ancestor class for a list of objects. -
getCommonClass
Returns the common ancestor class for two objects.
-