public class GridCacheDeepCloner extends Object implements GridCacheCloner
If isHonorCloneable() is set to true, then deep cloner will
first check if the passed in object implements Cloneable interface and,
if it does, will delegate to clone() method. It is advisable for
instances that need to be cloned to implement Cloneable, as cloning
this way will generally be faster than reflection-based cloning.
This implementation will first check if the object to clone has an empty
constructor. If it does, then it will be instantiated using such constructor.
Otherwise an empty constructor will be fetched from JDK and used instead.
Note that this behavior may not work on some JDKs in which case
cloneValue(Object) method will result in GridException
being thrown.
| Constructor and Description |
|---|
GridCacheDeepCloner()
Creates deep cloner with
isHonorCloneable() flag set to true. |
GridCacheDeepCloner(boolean honorCloneable)
Creates a new instance of deep cloner with specified flag to honor
Cloneable interface or not. |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
cloneValue(T val) |
boolean |
isHonorCloneable()
Gets flag indicating if
Cloneable interface should be honored
when cloning, or if reflection-based deep cloning should always be performed. |
void |
setHonorCloneable(boolean honorCloneable)
Sets flag indicating if
Cloneable interface should be honored
when cloning, or if reflection-based deep cloning should always be performed. |
public GridCacheDeepCloner()
isHonorCloneable() flag set to true.public boolean isHonorCloneable()
Cloneable interface should be honored
when cloning, or if reflection-based deep cloning should always be performed.Cloneable interface should be honored
when cloningpublic void setHonorCloneable(boolean honorCloneable)
Cloneable interface should be honored
when cloning, or if reflection-based deep cloning should always be performed.honorCloneable - Flag indicating whether Cloneable interface
should be honored or not when cloning.public <T> T cloneValue(T val)
throws GridException
cloneValue in interface GridCacheClonerval - Object to make a clone for.GridException - If failed to clone given object.Copyright © 2014. All rights reserved.