Top Description Fields Constructors Methods
org.springframework.objenesis.strategy

public Class SingleInstantiatorStrategy

extends Object
implements InstantiatorStrategy
Class Inheritance
All Implemented Interfaces
org.springframework.objenesis.strategy.InstantiatorStrategy
Imports
org.springframework.objenesis.ObjenesisException, org.springframework.objenesis.instantiator.ObjectInstantiator, java.lang.reflect.Constructor, .InvocationTargetException

Strategy returning only one instantiator type. Useful if you know on which JVM Objenesis will be used and want to specify it explicitly.
Author
Henri Tremblay

Field Summary

Modifier and TypeField and Description
private final Constructor<?>

Constructor Summary

AccessConstructor and Description
public <
the type we want to instantiate
T extends ObjectInstantiator<?>
>
SingleInstantiatorStrategy(Class<T>
the instantiator type
instantiator
)

Create a strategy that will return always the same instantiator type.

Method Summary

Modifier and TypeMethod and Description
public <
the type we want to instantiate
T
>
ObjectInstantiator<T>

Returns:

The ObjectInstantiator for the class
newInstantiatorOf
(Class<T>
Class to instantiate
type
)

Implements org.springframework.objenesis.strategy.InstantiatorStrategy.newInstantiatorOf.

Return an instantiator for the wanted type and of the one and only type of instantiator returned by this class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constructorback to summary
private final Constructor<?> constructor

Constructor Detail

SingleInstantiatorStrategyback to summary
public <T extends ObjectInstantiator<?>> SingleInstantiatorStrategy(Class<T> instantiator)

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.

Parameters
<T>
the type we want to instantiate
instantiator:Class<T>

the instantiator type

Method Detail

newInstantiatorOfback to summary
public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type)

Implements org.springframework.objenesis.strategy.InstantiatorStrategy.newInstantiatorOf.

Return an instantiator for the wanted type and of the one and only type of instantiator returned by this class.

Parameters
<T>
the type we want to instantiate
type:Class<T>

Class to instantiate

Returns:ObjectInstantiator<T>

The ObjectInstantiator for the class

Annotations
@SuppressWarnings:unchecked