r01f.reflection.fluent
Class ConstructorInvoker<T>

java.lang.Object
  extended by r01f.reflection.fluent.ConstructorInvoker<T>
Type Parameters:
T - the class in which the constructor is declared. Usage example:
 // Equivalent to call 'new MyObj()' 
 MyObj p = Reflection.constructor().in(MyObj.class).newInstance(); 
 // Equivalent to call 'new MyObj("myStrParam")' 
 Person p = Reflection.constructor().withParameterTypes(String.class).in(MyObj.class).newInstance("myStrParam");
 

public final class ConstructorInvoker<T>
extends java.lang.Object

Contructor invocation via reflection


Field Summary
private  java.lang.reflect.Constructor<T> _constructor
           
 
Constructor Summary
private ConstructorInvoker(java.lang.reflect.Constructor<T> constructor)
           
 
Method Summary
private static
<T> java.lang.reflect.Constructor<T>
constructor(java.lang.Class<T> target, java.lang.Class<?>... parameterTypes)
           
 java.lang.reflect.Constructor<T> getConstructor()
          Returns the "real" constructor managed by this class.
 T newInstance(java.lang.Object... args)
          Creates a new instance of T by calling a constructor with the given arguments.
static
<T> ConstructorInvoker<T>
newInvoker(java.lang.Class<T> target, java.lang.Class<?>... parameterTypes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_constructor

private final java.lang.reflect.Constructor<T> _constructor
Constructor Detail

ConstructorInvoker

private ConstructorInvoker(java.lang.reflect.Constructor<T> constructor)
Method Detail

newInvoker

public static <T> ConstructorInvoker<T> newInvoker(java.lang.Class<T> target,
                                                   java.lang.Class<?>... parameterTypes)

newInstance

public T newInstance(java.lang.Object... args)
Creates a new instance of T by calling a constructor with the given arguments.

Parameters:
args - the arguments to pass to the constructor (can be zero or more).
Returns:
the created instance of T.
Throws:
ReflectionException - if a new instance cannot be created.

getConstructor

public java.lang.reflect.Constructor<T> getConstructor()
Returns the "real" constructor managed by this class.

Returns:
the "real" constructor managed by this class.

constructor

private static <T> java.lang.reflect.Constructor<T> constructor(java.lang.Class<T> target,
                                                                java.lang.Class<?>... parameterTypes)