messif.utility.reflection
Interface Instantiator<T>

Type Parameters:
T - the class the instances of which will be created by this Instantiator
All Known Implementing Classes:
ConstructorInstantiator, FactoryMethodInstantiator, FieldInstantiator

public interface Instantiator<T>

Interface for creating instances of a given class.

This class provides a convenient way of repeatable creation of instances without the need of repetable inspection of the target class.


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 instantiate(java.lang.Object[]) method.
 T instantiate(java.lang.Object... arguments)
          Creates an instance for the given arguments.
 

Method Detail

instantiate

T instantiate(java.lang.Object... arguments)
              throws java.lang.IllegalArgumentException,
                     java.lang.reflect.InvocationTargetException
Creates an instance for the given arguments.

Parameters:
arguments - the arguments for the intstance
Returns:
a new instance
Throws:
java.lang.IllegalArgumentException - if the arguments are not compatible
java.lang.reflect.InvocationTargetException - if there was an exception thrown when the instance was created

getInstantiatorClass

java.lang.Class<? extends T> getInstantiatorClass()
Returns the class instantiated by this Instantiator.

Returns:
the instantiated class

getInstantiatorPrototype

java.lang.Class<?>[] getInstantiatorPrototype()
Returns the classes of arguments for the instantiate(java.lang.Object[]) method.

Returns:
the prototype of instantiatior arguments