Package com.inductiveautomation.rm.base
Class RMClassUtils
java.lang.Object
com.inductiveautomation.rm.base.RMClassUtils
Utility methods for Class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Class
fromPrimitive
(Class aClass) Returns primitive type for non-primitive.static Class
Returns the class for an object.static Class[]
getClasses
(String aPackageName) Returns the classes in a package name.static Class
getClassForName
(String aName) Returns a class for a given name.static Class
getClassForName
(String aName, Object anObj) Returns a class for a given name, using the class loader of the given class.static String
getClassSimpleName
(Object anObj) Returns simple class name of an object.static String
getClassStandardName
(Object anObj, boolean doSimple) Returns a standard class name of an object, minus any weird notation, like inner-class $, etc.static Class
getCommonClass
(Object... theObjects) Returns the common ancestor class for a list of objects.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 Class
getDeclaredClass
(Class aClass, String aName) Returns a class for a parent class and a name.static Field
getDeclaredField
(Class aClass, String aName) Returns a field for a parent class and a name.static Method
getDeclaredMethod
(Class aClass, String aName, Class[] theClasses) Returns the declared method for a given class, name and parameter types array.static Field
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 URL
Returns the Jar URL for given class.static String
getJarURLS
(Class aClass) Returns the root URL for given class (could be a "file:" (directory) or "jar:").static Method
Returns the method for given class, name and parameter types.static Class
getPrimitiveClassForName
(String aName) Returns a primitive class for name.static URL
getRootURL
(Class aClass) Returns the plain URL (http: or file:) to the jar for given class.static Class
getTypeParameterClass
(Class aClass) Returns a type parameter class.static boolean
isAssignable
(Class[] theClasses1, Class[] theClasses2, int aCount) Returns whether second batch of classes is assignable to first batch of classes (accounting for auto-boxing).static boolean
isAssignable
(Class aClass1, Class aClass2) Returns whether a given class could be assigned a value from the second given class (accounting for auto-boxing).static boolean
isAssignablePrimitive
(Class aClass1, Class aClass2) Returns whether a given primitive class could be assigned a value from the second given class.static boolean
isCompatible
(Method aMethod, Class[] theClasses) Returns whether arg classes are compatible.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 <T> T
newInstance
(T anObject) Returns a new instance of a given object.static Class
toPrimitive
(Class aClass) Returns non primitive type for primitive.
-
Method Details
-
getClass
Returns the class for an object. -
getInstance
Returns the given object as instance of given class, if it is. -
getClassSimpleName
Returns simple class name of an object. -
getClassStandardName
Returns a standard class name of an object, minus any weird notation, like inner-class $, etc. -
getClassForName
Returns a class for a given name. -
getClassForName
Returns a class for a given name, using the class loader of the given class. -
isPrimitiveClassName
Returns whether name is a primitive class name. -
getPrimitiveClassForName
Returns a primitive class for name. -
newInstance
public static <T> T newInstance(@Nonnull T anObject) Returns a new instance of a given object. -
newInstance
Returns a new instance of a given class. -
getField
Returns a field for a parent class and a name. -
getDeclaredField
Returns a field for a parent class and a name. -
getMethod
Returns the method for given class, name and parameter types. -
getDeclaredMethod
Returns the declared method for a given class, name and parameter types array. -
getDeclaredClass
Returns a class for a parent class and a name. -
isCompatible
Returns whether arg classes are compatible. -
isAssignable
Returns whether second batch of classes is assignable to first batch of classes (accounting for auto-boxing). -
isAssignable
Returns whether a given class could be assigned a value from the second given class (accounting for auto-boxing). -
isAssignablePrimitive
Returns whether a given primitive class could be assigned a value from the second given class. -
toPrimitive
Returns non primitive type for primitive. -
fromPrimitive
Returns primitive type for non-primitive. -
getCommonClass
Returns the common ancestor class for two objects. -
getCommonClass
Returns the common ancestor class for a list of objects. -
getCommonClass
Returns the common ancestor class for a list of objects. -
getTypeParameterClass
Returns a type parameter class. -
getClasses
Returns the classes in a package name. Busted for JNLP Web Start. -
getRootURL
Returns the plain URL (http: or file:) to the jar for given class. -
getJarURL
Returns the Jar URL for given class. -
getJarURLS
Returns the root URL for given class (could be a "file:" (directory) or "jar:").
-