|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.utility.reflection.ConstructorInstantiator<T>
T
- the class the instances of which will be created by this ConstructorInstantiatorpublic class ConstructorInstantiator<T>
This class allows to create instances of a given class. A constructor with the given prototype is encapsulated and used in subsequent calls.
This class provides a convenient way of repeatable creation of instances of a given class without the need of repetable constructor retrieval and checking all the exceptions.
Constructor Summary | |
---|---|
ConstructorInstantiator(java.lang.Class<? extends T> objectClass,
java.lang.Class<?>... prototype)
Creates a new instance of ConstructorInstantiator for creating instances of objectClass that accepts parameters of the given prototype. |
|
ConstructorInstantiator(java.lang.Class<? extends T> objectClass,
int argumentCount)
Creates a new instance of ConstructorInstantiator for creating instances of objectClass that accepts the given number of arguments. |
|
ConstructorInstantiator(java.lang.Class<? extends T> objectClass,
java.lang.Object... arguments)
Creates a new instance of ConstructorInstantiator for creating instances of objectClass that accepts the given arguments. |
|
ConstructorInstantiator(java.lang.reflect.Constructor<? extends T> constructor)
Creates a new instance of ConstructorInstantiator for creating instances of objectClass via the specified constructor. |
Method Summary | |
---|---|
java.lang.Class<? extends T> |
getInstantiatorClass()
Returns the class instantiated by this Instantiator. |
java.lang.Class<?>[] |
getInstantiatorPrototype()
Returns the classes of arguments for the Instantiator.instantiate(java.lang.Object[]) method. |
T |
instantiate(java.lang.Object... arguments)
Creates a new instance using the encapsulated constructor. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConstructorInstantiator(java.lang.reflect.Constructor<? extends T> constructor) throws java.lang.IllegalArgumentException
objectClass
via the specified constructor.
constructor
- the constructor using which the instances will be created
java.lang.IllegalArgumentException
- if the provided class does not have a proper constructorpublic ConstructorInstantiator(java.lang.Class<? extends T> objectClass, java.lang.Class<?>... prototype) throws java.lang.IllegalArgumentException
objectClass
that accepts parameters of the given prototype.
objectClass
- the class the instances of which will be createdprototype
- the types of constructor arguments
java.lang.IllegalArgumentException
- if the provided class does not have a proper constructorpublic ConstructorInstantiator(java.lang.Class<? extends T> objectClass, int argumentCount) throws java.lang.IllegalArgumentException
objectClass
that accepts the given number of arguments.
Note that if there are several constructors with the same number of arguments,
one is selected.
objectClass
- the class the instances of which will be createdargumentCount
- the number of arguments that the constructor should have
java.lang.IllegalArgumentException
- if the provided class does not have a proper constructorpublic ConstructorInstantiator(java.lang.Class<? extends T> objectClass, java.lang.Object... arguments) throws java.lang.IllegalArgumentException
objectClass
that accepts the given arguments.
objectClass
- the class the instances of which will be createdarguments
- the arguments for the constructor
java.lang.IllegalArgumentException
- if the provided class does not have a proper constructorMethod Detail |
---|
public T instantiate(java.lang.Object... arguments) throws java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
creating
this
ConstructorInstantiator
class.
instantiate
in interface Instantiator<T>
arguments
- the arguments for the encapsulated constructor
java.lang.IllegalArgumentException
- if the arguments are not compatible with the constructor prototype
java.lang.reflect.InvocationTargetException
- if there was an exception thrown when the constructor was invokedpublic java.lang.Class<?>[] getInstantiatorPrototype()
Instantiator
Instantiator.instantiate(java.lang.Object[])
method.
getInstantiatorPrototype
in interface Instantiator<T>
public java.lang.Class<? extends T> getInstantiatorClass()
Instantiator
getInstantiatorClass
in interface Instantiator<T>
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |