|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.pfl.dynamic.copyobject.impl.ClassCopierBase
public abstract class ClassCopierBase
A convenient base class for making ClassCopier types. This takes care of checking oldToNew and updating oldToNew when an actual copy is made. All subclasses must override createCopy, which allocates a new result. In some simple cases, this is all that is needed. In the more complex cases, doCopy must also be overridden to make the actual copy.
| Constructor Summary | |
|---|---|
protected |
ClassCopierBase(String name)
Pass a name here that can be used for toString, hashCode, and equals. |
protected |
ClassCopierBase(String name,
boolean isReflective)
|
| Method Summary | |
|---|---|
Object |
copy(Map<Object,Object> oldToNew,
Object source)
Make the actual copy of source, using oldToNew to preserve aliasing. |
protected abstract Object |
createCopy(Object source)
Create a copy of source. |
protected Object |
doCopy(Map<Object,Object> oldToNew,
Object source,
Object result)
Do the copying of data from source to result. |
boolean |
equals(Object obj)
|
int |
hashCode()
|
boolean |
isReflectiveClassCopier()
We need to know whether this class copier operates via reflection or not, as the reflective class copier must be able to tell when a super class is copied by an incompatible copier. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected ClassCopierBase(String name)
protected ClassCopierBase(String name,
boolean isReflective)
| Method Detail |
|---|
public final String toString()
toString in class Objectpublic final int hashCode()
hashCode in class Objectpublic final boolean equals(Object obj)
equals in class Object
public final Object copy(Map<Object,Object> oldToNew,
Object source)
throws ReflectiveCopyException
This split into two phases isolates all subclasses from the need to update oldToNew. It accommodates simple cases (arrays of primitives for example) that only need to define createCopy, as well as more complex case (general objects) that must first create the copy, update oldToNew, and then do the copy, as otherwise self-references would cause infinite recursion.
copy in interface ClassCopierReflectiveCopyExceptionpublic boolean isReflectiveClassCopier()
ClassCopier
isReflectiveClassCopier in interface ClassCopier
protected abstract Object createCopy(Object source)
throws ReflectiveCopyException
ReflectiveCopyException
protected Object doCopy(Map<Object,Object> oldToNew,
Object source,
Object result)
throws ReflectiveCopyException
ReflectiveCopyException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||