|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.clone.CloneUtils
public class CloneUtils
Collection of utility methods to simplify cloning.
Constructor Summary | |
---|---|
CloneUtils()
|
Method Summary | |
---|---|
static java.lang.Object |
cloneAsDeepAsPossible(java.lang.Object o)
Clone the provided object if supported. |
static java.lang.Object |
cloneAsDeepAsPossible(java.lang.Object o,
int maxDepth)
Clone the provided object if supported. |
static void |
cloneMapEntries(java.util.Map<java.lang.String,java.lang.Object> source,
java.util.Map<java.lang.String,java.lang.Object> target)
Duplicate all entries of the source map to the target map and create clones of all contained objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CloneUtils()
Method Detail |
---|
public static void cloneMapEntries(java.util.Map<java.lang.String,java.lang.Object> source, java.util.Map<java.lang.String,java.lang.Object> target) throws DeepCloneException
source
- the source for the key value pairs.target
- the map to insert the created clones into.
DeepCloneException
public static java.lang.Object cloneAsDeepAsPossible(java.lang.Object o) throws DeepCloneException
cloneAsDeepAsPossible(Object, int)
.
o
- the object to be cloned.
DeepCloneException
- if the depth of the cloned struture is too high or the
underlying clone methods failed.public static java.lang.Object cloneAsDeepAsPossible(java.lang.Object o, int maxDepth) throws DeepCloneException
IDeepCloneable
s the IDeepCloneable.deepClone()
method is used, ignoring the maximal depth.Map
s the contents (keys and values) are cloned and put
into a HashMap
. The order is not preserved.Collection
s are cloned as an ArrayList
Cloneable
, and has a public clone method, the
Object.clone()
method is used.
o
- the object to be cloned.maxDepth
- the maximal depth of the structure before an exception is
thrown. A depth of 0 indicates that no recursive calls are
allowed, depth 1 allows 1 recursive call, and so on.
DeepCloneException
- if the depth of the cloned struture is too high or the
underlying clone methods failed.
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |