public class ObjenesisBase extends Object implements Objenesis
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap<String,ObjectInstantiator<?>> |
cache
Strategy cache.
|
protected InstantiatorStrategy |
strategy
Strategy used by this Objenesis implementation to create classes
|
Constructor and Description |
---|
ObjenesisBase(InstantiatorStrategy strategy)
Constructor allowing to pick a strategy and using cache
|
ObjenesisBase(InstantiatorStrategy strategy,
boolean useCache)
Flexible constructor allowing to pick the strategy and if caching should be used
|
Modifier and Type | Method and Description |
---|---|
<T> ObjectInstantiator<T> |
getInstantiatorOf(Class<T> clazz)
Will pick the best instantiator for the provided class.
|
<T> T |
newInstance(Class<T> clazz)
Will create a new object without any constructor being called
|
String |
toString() |
protected final InstantiatorStrategy strategy
protected ConcurrentHashMap<String,ObjectInstantiator<?>> cache
public ObjenesisBase(InstantiatorStrategy strategy)
strategy
- Strategy to usepublic ObjenesisBase(InstantiatorStrategy strategy, boolean useCache)
strategy
- Strategy to useuseCache
- If ObjectInstantiator
s should be cachedpublic <T> T newInstance(Class<T> clazz)
newInstance
in interface Objenesis
T
- Type instantiatedclazz
- Class to instantiatepublic <T> ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz)
newInstance(Class)
.getInstantiatorOf
in interface Objenesis
T
- Type to instantiateclazz
- Class to instantiateCopyright © 2006–2024 Joe Walnes, Henri Tremblay, Leonardo Mesquita. All rights reserved.