public class InstanceFactory
extends java.lang.Object
Constructor and Description |
---|
InstanceFactory() |
Modifier and Type | Method and Description |
---|---|
java.lang.Class<?> |
getImplementationClazz(java.lang.Class<?> clazz)
Tries to find the concrete implementation of a class (interface, abstract class, etc.).
|
java.lang.Object |
getInstance(java.lang.Class<?> clazz)
Returns an instance of type T
|
java.lang.Object |
getInstance(java.lang.Class<?> clazz,
java.lang.String arg)
Creates an instance of the given class using the string argument
|
java.lang.Object |
getInstance(GenericType type)
Returns an instance of type T
|
boolean |
hasStringArgConstructor(java.lang.Class<?> clazz)
Tests if the given class has a string argument constructor
|
public java.lang.Object getInstance(GenericType type) throws ObjectCreationException
type
- type informationObjectCreationException
- unable to create instancepublic java.lang.Class<?> getImplementationClazz(java.lang.Class<?> clazz) throws java.lang.ClassNotFoundException
clazz
- target classjava.lang.ClassNotFoundException
- if the actual implementation can't be foundpublic java.lang.Object getInstance(java.lang.Class<?> clazz) throws ObjectCreationException
clazz
- class, abstract class or interfaceObjectCreationException
- if unable to instantiate a class or if there is no implementation classpublic java.lang.Object getInstance(java.lang.Class<?> clazz, java.lang.String arg) throws ObjectCreationException
clazz
- target classarg
- constructor argumentObjectCreationException
- unable to create an instance of the given typepublic boolean hasStringArgConstructor(java.lang.Class<?> clazz)
clazz
- class to test