Package org.fest.reflect.constructor
Class Invoker<T>
java.lang.Object
org.fest.reflect.constructor.Invoker<T>
- Type Parameters:
T- the class in which the constructor is declared.The following is an example of proper usage of the classes in this package:
// Equivalent to call 'new Person()' Person p =
constructor().in(Person.class).newInstance(); // Equivalent to call 'new Person("Yoda")' Person p =constructor().withParameterTypes(String.class).in(Person.class).newInstance("Yoda");
Understands the invocation of a constructor via Java Reflection.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> Constructor<T>constructor(Class<T> target, Class<?>... parameterTypes) info()Returns the "real" constructor managed by this class.newInstance(Object... args) Creates a new instance ofTby calling a constructor with the given arguments.static <T> Invoker<T>newInvoker(Class<T> target, Class<?>... parameterTypes)
-
Field Details
-
constructor
-
-
Constructor Details
-
Invoker
-
-
Method Details
-
newInvoker
-
constructor
-
newInstance
Creates a new instance ofTby 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:
ReflectionError- if a new instance cannot be created.
-
info
Returns the "real" constructor managed by this class.- Returns:
- the "real" constructor managed by this class.
-