public final class JavaTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
instantiate(java.lang.String className,
java.lang.Class<T> outputClass)
Instantiate a class by reflection.
|
static <T> T |
instantiateFactory(java.lang.String classname,
java.lang.Class<T> outputClass)
Instantiate a factory class by reflection.
|
public static <T> T instantiate(java.lang.String className, java.lang.Class<T> outputClass)
T
- The desired return type.className
- The class name to instantiate.outputClass
- The class that specifies the type that should be returned. This will usually be a superclass of the given class name.public static <T> T instantiateFactory(java.lang.String classname, java.lang.Class<T> outputClass)
instantiate(String, Class)
except that it will look for a static field called INSTANCE that contains an instance of the right class. If this doesn't exist (or in inaccessable or the wrong type) then a constructor will be used.T
- The desired return type.classname
- The class name to instantiate.outputClass
- The class that specifies the type that should be returned. This will usually be a superclass of the given class name.