Class ReflectionUtils


  • public class ReflectionUtils
    extends java.lang.Object
    General Class Reflection Utils.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReflectionUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.lang.Class<? extends T> forName​(java.lang.String className, java.lang.Class<T> xface)
      Returns the Class object object associated with the class or interface with the given string name, which is a subclass of xface.
      static java.lang.Class<?> getClass​(org.apache.commons.configuration.Configuration conf, java.lang.String name, java.lang.Class<?> defaultCls, java.lang.ClassLoader classLoader)
      Get the value of the name property as a Class.
      static <T> java.lang.Class<? extends T> getClass​(org.apache.commons.configuration.Configuration conf, java.lang.String name, java.lang.Class<? extends T> defaultValue, java.lang.Class<T> xface, java.lang.ClassLoader classLoader)
      Get the value of the name property as a Class implementing the interface specified by xface.
      static <T> T newInstance​(java.lang.Class<T> theCls)
      Create an object for the given class.
      static <T> T newInstance​(java.lang.String clsName, java.lang.Class<T> xface)
      Create an object using the given class name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReflectionUtils

        public ReflectionUtils()
    • Method Detail

      • forName

        public static <T> java.lang.Class<? extends T> forName​(java.lang.String className,
                                                               java.lang.Class<T> xface)
        Returns the Class object object associated with the class or interface with the given string name, which is a subclass of xface.
        Parameters:
        className - class name
        xface - class interface
        Returns:
        the class object associated with the class or interface with the given string name.
      • getClass

        public static java.lang.Class<?> getClass​(org.apache.commons.configuration.Configuration conf,
                                                  java.lang.String name,
                                                  java.lang.Class<?> defaultCls,
                                                  java.lang.ClassLoader classLoader)
                                           throws org.apache.commons.configuration.ConfigurationException
        Get the value of the name property as a Class. If no such property is specified, then defaultCls is returned.
        Parameters:
        conf - Configuration Object.
        name - Class Property Name.
        defaultCls - Default Class to be returned.
        classLoader - Class Loader to load class.
        Returns:
        property value as a Class, or defaultCls.
        Throws:
        org.apache.commons.configuration.ConfigurationException
      • getClass

        public static <T> java.lang.Class<? extends T> getClass​(org.apache.commons.configuration.Configuration conf,
                                                                java.lang.String name,
                                                                java.lang.Class<? extends T> defaultValue,
                                                                java.lang.Class<T> xface,
                                                                java.lang.ClassLoader classLoader)
                                                         throws org.apache.commons.configuration.ConfigurationException
        Get the value of the name property as a Class implementing the interface specified by xface.

        If no such property is specified, then defaultValue is returned.

        An exception is thrown if the returned class does not implement the named interface.

        Parameters:
        conf - Configuration Object.
        name - Class Property Name.
        defaultValue - Default Class to be returned.
        xface - The interface implemented by the named class.
        classLoader - Class Loader to load class.
        Returns:
        property value as a Class, or defaultValue.
        Throws:
        org.apache.commons.configuration.ConfigurationException
      • newInstance

        public static <T> T newInstance​(java.lang.Class<T> theCls)
        Create an object for the given class.
        Parameters:
        theCls - class of which an object is created.
        Returns:
        a new object
      • newInstance

        public static <T> T newInstance​(java.lang.String clsName,
                                        java.lang.Class<T> xface)
        Create an object using the given class name.
        Parameters:
        clsName - class name of which an object is created.
        xface - The interface implemented by the named class.
        Returns:
        a new object