Package org.objenesis.strategy
Class SingleInstantiatorStrategy
java.lang.Object
org.objenesis.strategy.SingleInstantiatorStrategy
- All Implemented Interfaces:
InstantiatorStrategy
Strategy returning only one instantiator type. Useful if you know on which JVM Objenesis
will be used and want to specify it explicitly.
-
Constructor Summary
ConstructorsConstructorDescriptionSingleInstantiatorStrategy
(Class<T> instantiator) Create a strategy that will return always the same instantiator type. -
Method Summary
Modifier and TypeMethodDescription<T> ObjectInstantiator
<T> newInstantiatorOf
(Class<T> type) Return an instantiator for the wanted type and of the one and only type of instantiator returned by this class.
-
Constructor Details
-
SingleInstantiatorStrategy
Create a strategy that will return always the same instantiator type. We assume this instantiator has one constructor taking the class to instantiate in parameter.- Type Parameters:
T
- the type we want to instantiate- Parameters:
instantiator
- the instantiator type
-
-
Method Details
-
newInstantiatorOf
Return an instantiator for the wanted type and of the one and only type of instantiator returned by this class.- Specified by:
newInstantiatorOf
in interfaceInstantiatorStrategy
- Type Parameters:
T
- the type we want to instantiate- Parameters:
type
- Class to instantiate- Returns:
- The ObjectInstantiator for the class
-