public class FastCloner extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FastCloner.FastClonerArrayList |
static class |
FastCloner.FastClonerCalendar |
static class |
FastCloner.FastClonerCustomCollection<T extends Collection> |
static class |
FastCloner.FastClonerHashMap |
static class |
FastCloner.FastClonerHashSet |
static class |
FastCloner.FastClonerLinkedList |
static class |
FastCloner.FastClonerTreeMap |
static interface |
FastCloner.IFastCloner |
Constructor and Description |
---|
FastCloner() |
Modifier and Type | Method and Description |
---|---|
protected <T> T |
cloneInternal(T o,
Map<Object,Object> clones)
PLEASE DONT CALL THIS METHOD The only reason for been public is because IFastCloner must invoke it
|
<T,E extends T> |
copyPropertiesOfInheritedClass(T src,
E dest)
copies all properties from src to dest.
|
<T> T |
deepClone(T o)
deep clones "o".
|
void |
dontClone(Class<?>... c)
instances of classes that shouldn't be cloned can be registered using this method.
|
protected Object |
fastClone(Object o,
Map<Object,Object> clones) |
<T> T |
fastCloneOrNewInstance(Class<T> c) |
boolean |
isCloningEnabled() |
boolean |
isDumpClonedClasses() |
boolean |
isNullTransient() |
void |
nullInsteadOfClone(Class<?>... c)
instead of cloning these classes will set the field to null
|
void |
registerConstant(Class<?> c,
String privateFieldName) |
void |
registerConstant(Object o) |
void |
registerFastCloner(Class<?> c,
FastCloner.IFastCloner fastCloner) |
protected void |
registerFastCloners()
registers a std set of fast cloners.
|
void |
registerImmutable(Class<?>... c)
registers an immutable class.
|
protected void |
registerKnownConstants() |
protected void |
registerKnownJdkImmutableClasses()
registers some known JDK immutable classes.
|
void |
registerStaticFields(Class<?>... classes)
registers all static fields of these classes.
|
void |
setCloningEnabled(boolean cloningEnabled) |
void |
setDumpClonedClasses(boolean dumpClonedClasses)
will println() all cloned classes.
|
void |
setExtraImmutables(Set<Class<?>> set)
spring framework friendly version of registerImmutable
|
void |
setExtraNullInsteadOfClone(Set<Class<?>> set)
spring framework friendly version of nullInsteadOfClone
|
void |
setExtraStaticFields(Set<Class<?>> set)
spring framework friendly version of registerStaticFields
|
void |
setNullTransient(boolean nullTransient)
this makes the cloner to set a transient field to null upon cloning.
|
<T> T |
shallowClone(T o)
shallow clones "o".
|
public boolean isNullTransient()
public void setNullTransient(boolean nullTransient)
nullTransient
- true for transient fields to be nulledprotected void registerFastCloners()
protected Object fastClone(Object o, Map<Object,Object> clones) throws IllegalAccessException
IllegalAccessException
public void registerConstant(Object o)
protected void registerKnownJdkImmutableClasses()
protected void registerKnownConstants()
public void registerStaticFields(Class<?>... classes)
classes
- array of classespublic void setExtraStaticFields(Set<Class<?>> set)
set
- a set of classes which will be scanned for static fieldspublic void dontClone(Class<?>... c)
c
- The class that shouldn't be cloned. That is, whenever a deep clone for an object is created and c is encountered, the object
instance of c will be added to the clone.public void nullInsteadOfClone(Class<?>... c)
c
- the classes to nullify during cloningpublic void setExtraNullInsteadOfClone(Set<Class<?>> set)
public void registerImmutable(Class<?>... c)
c
- the immutable classpublic void setExtraImmutables(Set<Class<?>> set)
public void registerFastCloner(Class<?> c, FastCloner.IFastCloner fastCloner)
public <T> T fastCloneOrNewInstance(Class<T> c)
public <T> T deepClone(T o)
T
- the type of "o"o
- the object to be deep-clonedpublic <T> T shallowClone(T o)
T
- the type of oo
- the object to be shallow-clonedprotected <T> T cloneInternal(T o, Map<Object,Object> clones) throws IllegalAccessException
IllegalAccessException
public <T,E extends T> void copyPropertiesOfInheritedClass(T src, E dest)
src
- the source objectdest
- the destination object which must contain as minimul all the fields of srcpublic boolean isDumpClonedClasses()
public void setDumpClonedClasses(boolean dumpClonedClasses)
dumpClonedClasses
- true to enable printing all cloned classespublic boolean isCloningEnabled()
public void setCloningEnabled(boolean cloningEnabled)
Copyright © 2001-2015 JBoss by Red Hat. All Rights Reserved.