Class RMClassUtils

java.lang.Object
com.inductiveautomation.rm.base.RMClassUtils

public class RMClassUtils extends Object
Utility methods for Class.
  • Method Details

    • getClass

      @Nullable public static Class getClass(Object anObj)
      Returns the class for an object.
    • getInstance

      public static <T> T getInstance(Object anObj, Class<T> aClass)
      Returns the given object as instance of given class, if it is.
    • getClassSimpleName

      @Nonnull public static String getClassSimpleName(Object anObj)
      Returns simple class name of an object.
    • getClassStandardName

      @Nonnull public static String getClassStandardName(Object anObj, boolean doSimple)
      Returns a standard class name of an object, minus any weird notation, like inner-class $, etc.
    • getClassForName

      public static Class getClassForName(String aName)
      Returns a class for a given name.
    • getClassForName

      public static Class getClassForName(String aName, Object anObj)
      Returns a class for a given name, using the class loader of the given class.
    • isPrimitiveClassName

      public static boolean isPrimitiveClassName(String aName)
      Returns whether name is a primitive class name.
    • getPrimitiveClassForName

      @Nullable public static Class getPrimitiveClassForName(String aName)
      Returns a primitive class for name.
    • newInstance

      public static <T> T newInstance(@Nonnull T anObject)
      Returns a new instance of a given object.
    • newInstance

      public static <T> T newInstance(Class<T> aClass)
      Returns a new instance of a given class.
    • getField

      public static Field getField(@Nonnull Class aClass, @Nullable String aName)
      Returns a field for a parent class and a name.
    • getDeclaredField

      public static Field getDeclaredField(@Nonnull Class aClass, @Nullable String aName)
      Returns a field for a parent class and a name.
    • getMethod

      public static Method getMethod(Class aClass, String aName, Class[] theClasses)
      Returns the method for given class, name and parameter types.
    • getDeclaredMethod

      public static Method getDeclaredMethod(Class aClass, String aName, Class[] theClasses)
      Returns the declared method for a given class, name and parameter types array.
    • getDeclaredClass

      public static Class getDeclaredClass(Class aClass, String aName)
      Returns a class for a parent class and a name.
    • isCompatible

      public static boolean isCompatible(Method aMethod, Class[] theClasses)
      Returns whether arg classes are compatible.
    • isAssignable

      public 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).
    • isAssignable

      public 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).
    • isAssignablePrimitive

      public static boolean isAssignablePrimitive(Class aClass1, Class aClass2)
      Returns whether a given primitive class could be assigned a value from the second given class.
    • toPrimitive

      public static Class toPrimitive(Class aClass)
      Returns non primitive type for primitive.
    • fromPrimitive

      public static Class fromPrimitive(Class aClass)
      Returns primitive type for non-primitive.
    • getCommonClass

      public static Class getCommonClass(Object anObj1, Object anObj2)
      Returns the common ancestor class for two objects.
    • getCommonClass

      public static Class getCommonClass(Object... theObjects)
      Returns the common ancestor class for a list of objects.
    • getCommonClass

      public static Class getCommonClass(List aList)
      Returns the common ancestor class for a list of objects.
    • getTypeParameterClass

      public static Class getTypeParameterClass(Class aClass)
      Returns a type parameter class.
    • getClasses

      public static Class[] getClasses(String aPackageName)
      Returns the classes in a package name. Busted for JNLP Web Start.
    • getRootURL

      public static URL getRootURL(Class aClass)
      Returns the plain URL (http: or file:) to the jar for given class.
    • getJarURL

      public static URL getJarURL(Class aClass)
      Returns the Jar URL for given class.
    • getJarURLS

      public static String getJarURLS(Class aClass)
      Returns the root URL for given class (could be a "file:" (directory) or "jar:").