public final class CopyHelper extends Object
Entries.
Here is a simple example of how to use CopyHelper.copy
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);
Cloneable,
Serializable,
DataSerializer,
GemFireCache.setCopyOnRead(boolean),
CacheTransactionManager| Modifier and Type | Method and Description |
|---|---|
static <T> T |
copy(T o)
Makes a copy of the specified object.
|
static <T> T |
deepCopy(T o)
Makes a deep copy of the specified object o using serialization, so the object has to be
serializable by GemFire.
|
static boolean |
isWellKnownImmutableInstance(Object o)
Return true if the given object is an instance of a well known immutable class.
|
public static boolean isWellKnownImmutableInstance(Object o)
o - the object to checkpublic 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
(e.g. 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.
o - the original object that a copy is needed ofCopyException - if copying fails because a class could not be found or could not be
serialized.deepCopy(Object)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.
o - the original object to be copiedCopyException - if copying fails because a class could not be found or could not be
serializedcopy(Object)