Package org.fest.reflect.constructor
Class TargetType
- java.lang.Object
-
- org.fest.reflect.constructor.TargetType
-
public final class TargetType extends java.lang.ObjectUnderstands the type of object that the constructor will create.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");- Author:
- Alex Ruiz, Yvonne Wang
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Invoker<T>in(java.lang.Class<T> target)Creates a new constructor invoker.static TargetTypestartConstructorAccess()Creates a newTargetType.ParameterTypeswithParameterTypes(java.lang.Class<?>... parameterTypes)Specifies the parameter types for the constructor to invoke.
-
-
-
Method Detail
-
startConstructorAccess
public static TargetType startConstructorAccess()
Creates a newTargetType.- Returns:
- the created
TargetType.
-
in
public <T> Invoker<T> in(java.lang.Class<T> target)
Creates a new constructor invoker.- Type Parameters:
T- the generic type of the class containing the constructor to invoke.- Parameters:
target- the the type of object that the constructor invoker will create.- Returns:
- the created constructor invoker.
-
withParameterTypes
public ParameterTypes withParameterTypes(java.lang.Class<?>... parameterTypes)
Specifies the parameter types for the constructor to invoke. This method call is optional if the constructor to call does not accept arguments.- Parameters:
parameterTypes- the types of the parameters to pass to the constructor.- Returns:
- the created parameter type holder.
- Throws:
java.lang.NullPointerException- if the given array isnull.
-
-