Top Description Fields Constructors Methods
org.springframework.objenesis

public final Class ObjenesisHelper

extends Object
Class Inheritance
Imports
java.io.Serializable, org.springframework.objenesis.instantiator.ObjectInstantiator

Use Objenesis in a static way. It is strongly not recommended to use this class.
Author
Henri Tremblay

Field Summary

Modifier and TypeField and Description
private static final Objenesis
private static final Objenesis

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
Type to instantiate
T
>
ObjectInstantiator<T>

Returns:

Instantiator dedicated to the class
getInstantiatorOf
(Class<T>
Class to instantiate
clazz
)

Will pick the best instantiator for the provided class.

public static <
Type to instantiate
T extends Serializable
>
ObjectInstantiator<T>

Returns:

Instantiator dedicated to the class
getSerializableObjectInstantiatorOf
(Class<T>
Class to instantiate
clazz
)

Same as getInstantiatorOf(Class) but providing an instantiator emulating ObjectInputStream.readObject behavior.

public static <
Type instantiated
T
>
T

Returns:

New instance of clazz
newInstance
(Class<T>
Class to instantiate
clazz
)

Will create a new object without any constructor being called

public static <
Type instantiated
T extends Serializable
>
T

Returns:

New instance of clazz
newSerializableInstance
(Class<T>
Class to instantiate
clazz
)

Will create an object just like it's done by ObjectInputStream.readObject (the default constructor of the first non serializable class will be called)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

OBJENESIS_SERIALIZERback to summary
private static final Objenesis OBJENESIS_SERIALIZER
OBJENESIS_STDback to summary
private static final Objenesis OBJENESIS_STD

Constructor Detail

ObjenesisHelperback to summary
private ObjenesisHelper()

Method Detail

getInstantiatorOfback to summary
public static <T> ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz)

Will pick the best instantiator for the provided class. If you need to create a lot of instances from the same class, it is way more efficient to create them from the same ObjectInstantiator than calling newInstance(Class).

Parameters
<T>
Type to instantiate
clazz:Class<T>

Class to instantiate

Returns:ObjectInstantiator<T>

Instantiator dedicated to the class

getSerializableObjectInstantiatorOfback to summary
public static <T extends Serializable> ObjectInstantiator<T> getSerializableObjectInstantiatorOf(Class<T> clazz)

Same as getInstantiatorOf(Class) but providing an instantiator emulating ObjectInputStream.readObject behavior.

Parameters
<T>
Type to instantiate
clazz:Class<T>

Class to instantiate

Returns:ObjectInstantiator<T>

Instantiator dedicated to the class

See Also
newSerializableInstance(Class)
newInstanceback to summary
public static <T> T newInstance(Class<T> clazz)

Will create a new object without any constructor being called

Parameters
<T>
Type instantiated
clazz:Class<T>

Class to instantiate

Returns:T

New instance of clazz

newSerializableInstanceback to summary
public static <T extends Serializable> T newSerializableInstance(Class<T> clazz)

Will create an object just like it's done by ObjectInputStream.readObject (the default constructor of the first non serializable class will be called)

Parameters
<T>
Type instantiated
clazz:Class<T>

Class to instantiate

Returns:T

New instance of clazz