public final class CopyHelper extends java.lang.Object
Here is a simple example of how to use
Object o = r.get("stringBuf"); StringBuffer s = (StringBuffer) CopyHelper.copy(o); s.append("... and they lived happily ever after. The End."); r.put("stringBuf", s);
|Modifier and Type||Method and Description|
Makes a copy of the specified object.
Makes a deep copy of the specified object o using serialization, so the object has to be serializable by GemFire.
Return true if the given object is an instance of a well known immutable class.
public static boolean isWellKnownImmutableInstance(java.lang.Object o)
o- the object to check
public static <T> T copy(T o)
Makes a copy of the specified object. The object returned is not guaranteed to be a deep copy of the original object, as explained below.
Copies can only be made if the original is a Cloneable or serializable by GemFire. If
o is a
well known immutable instance then it will
be returned without copying it.
If the argument o is an instance of
Cloneable, a copy is made by invoking
clone on it. Note that not all implementations of clone make deep copies
HashMap.clone). Otherwise, if the argument is not an
instance of Cloneable, a copy is made using serialization: if GemFire serialization is
implemented, it is used; otherwise, java serialization is used.
The difference between this method and
deepCopy, is that this method
uses clone if available, whereas deepCopy does not. As a result, for
Cloneable objects copied using this method, how deep a copy the returned object is
depends on its implementation of clone.
public static <T> T deepCopy(T o)
If o is a
well known immutable instance then it
will be returned without copying it.
The passed in object is serialized in memory, and then deserialized into a new instance, which is returned. If GemFire serialization is implemented for the object, it is used; otherwise, java serialization is used.