T
- the specific subclass of ERXCopyable
that is being copiedpublic interface ERXCopyable<T extends ERXCopyable<T>> extends ERXEnterpriseObject
EOEnterpriseObject
s, a default implementation for doing the actual
copying, and a Utility class that provides convenience methods to make
implementing the interface easier.
There are several ways to implement this interface:
Entity.java
class that
you want to be able to copy
@Override
public MyEntity copy() {
MyEntity copy = copy(new NSMutableDictionary<EOGlobalID, ERXCopyable<?>>());
return copy;
}
@Override
public MyEntity copy(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) {
MyEntity copy = ERXCopyable.DefaultImplementation.copy(copiedObjects, (MyEntity) this);
return copy;
}
@Override
public MyEntity duplicate(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) {
MyEntity duplicate = ERXCopyable.Utility.deepCopy(copiedObjects, (MyEntity) this);
return duplicate;
}
ERXGenericRecord
subclass
ERXGenericRecord
subclass implements
ERXCopyable<MyGenericRecord> in the class declaration and then
implement the required methods. The defaults are very similar to option #1:
@Override
public MyGenericRecord copy() {
MyGenericRecord copy = copy(new NSMutableDictionary<EOGlobalID, ERXCopyable<?>>());
return copy;
}
@Override
public MyGenericRecord copy(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) {
MyGenericRecord copy = ERXCopyable.DefaultImplementation.copy(copiedObjects, this);
return copy;
}
@Override
public MyGenericRecord duplicate(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) {
MyGenericRecord duplicate = ERXCopyable.Utility.deepCopy(copiedObjects, this);
return duplicate;
}
UserInfo
dictionary entries into your EOModel and make some
additions to your EOGenerator templates that will automatically implement
this interface based on your model settings.#if(${entity.userInfo.ERXCopyable}) import er.extensions.eof.ERXCopyable; #end
#if(${entity.userInfo.ERXCopyable}) implements ERXCopyable<${entity.classNameWithOptionalPackage}>#end
#if(${entity.userInfo.ERXCopyable} == 'Model' || ${entity.userInfo.ERXCopyable} == 'Default') public ${entity.classNameWithOptionalPackage} copy() { $entity.classNameWithOptionalPackage copy = copy(new NSMutableDictionary<EOGlobalID, ERXCopyable<?>>()); return copy; } public ${entity.classNameWithOptionalPackage} copy(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) { ${entity.classNameWithOptionalPackage} copy = duplicate(copiedObjects); return copy; } public ${entity.classNameWithOptionalPackage} duplicate(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) { #if(${entity.userInfo.ERXCopyable} == 'Model') ${entity.classNameWithOptionalPackage} duplicate = ERXCopyable.Utility.modelCopy(copiedObjects, (${entity.classNameWithOptionalPackage}) this); #elseif(${entity.userInfo.ERXCopyable} == 'Default') ${entity.classNameWithOptionalPackage} duplicate = ERXCopyable.Utility.deepCopy(copiedObjects, (${entity.classNameWithOptionalPackage}) this); #end return duplicate; } #end
Modifier and Type | Interface and Description |
---|---|
static class |
ERXCopyable.CopyType
|
static class |
ERXCopyable.DefaultImplementation
This class provides a default implementation of ERXCopyable that handles
the most common situations encountered copying
EOEnterpriseObject
s. |
static class |
ERXCopyable.Utility
This class provides utility methods for use implementing ERXCopyable.
|
ERXEnterpriseObject.Observer, ERXEnterpriseObject.Processor
com.webobjects.eocontrol.EOKeyValueCoding._BestBindingCreation, com.webobjects.eocontrol.EOKeyValueCoding._KeyBindingCreation, com.webobjects.eocontrol.EOKeyValueCoding._StoredForwardingBinding
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.MapImplementation, com.webobjects.foundation.NSKeyValueCoding.Null<T>, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
Modifier and Type | Field and Description |
---|---|
static String |
COPY_TYPE_KEY
"
ERXCopyable.CopyType " which is the exact String that must be
used as the key in an Attribute's or Relationship's EOModel UserInfo
dictionary to specify the way the property should be copied by
ERXCopyable . |
static org.slf4j.Logger |
copyLogger |
static String |
ERXCOPYABLE_KEY
"
ERXCopyable " which is the exact String that must be used as the
key in the Entity's EOModel UserInfo dictionary to designate it as
implementing ERXCopyable interface. |
applyRestrictingQualifierOnInsert, DidDeleteProcessor, DidInsertProcessor, DidRevertProcessor, DidUpdateProcessor, FlushCachesProcessor, insertionTrackingLog, KEY_MARKER, log, logMod, tranLogDidDelete, tranLogDidInsert, tranLogDidRevert, tranLogDidUpdate, tranLogMightDelete, tranLogWillDelete, tranLogWillInsert, tranLogWillRevert, tranLogWillUpdate, validation, validationException, WillDeleteProcessor, WillInsertProcessor, WillRevertProcessor, WillUpdateProcessor
Modifier and Type | Method and Description |
---|---|
T |
copy()
Convenience cover method for
copy(NSMutableDictionary) that
creates the dictionary for you. |
T |
copy(NSMutableDictionary<com.webobjects.eocontrol.EOGlobalID,ERXCopyable<?>> copiedObjects)
Returns a copy of this object, copying related objects as well.
|
T |
duplicate(NSMutableDictionary<com.webobjects.eocontrol.EOGlobalID,ERXCopyable<?>> copiedObjects)
Returns a copy of this object.
|
_setUpdateInverseRelationships, addObjectsToBothSidesOfRelationshipWithKey, changesFromCommittedSnapshot, committedSnapshotValueForKey, didDelete, didInsert, didRevert, didUpdate, encryptedPrimaryKey, flushCaches, foreignKeyForRelationshipWithKey, getClassLog, isDeletedEO, isNewObject, localInstanceIn, localInstanceOf, localInstancesOf, mightDelete, parentObjectStoreIsObjectStoreCoordinator, primaryKey, primaryKeyAttributeNames, primaryKeyInTransaction, rawPrimaryKey, rawPrimaryKeyInTransaction, refetchObjectFromDBinEditingContext, removeObjectsFromBothSidesOfRelationshipWithKey, removeObjectsFromPropertyWithKey, self, toLongString, trimSpaces, willDelete, willInsert, willRevert, willUpdate
allPropertyKeys, attributeKeys, awakeFromClientUpdate, awakeFromFetch, awakeFromInsertion, changesFromSnapshot, classDescription, classDescriptionForDestinationKey, clearProperties, deleteRuleForRelationshipKey, editingContext, entityName, eoDescription, eoShallowDescription, inverseForRelationshipKey, invokeRemoteMethod, isReadOnly, isToManyKey, opaqueState, ownsDestinationObjectsForRelationshipKey, prepareValuesForClient, propagateDeleteWithEditingContext, reapplyChangesFromDictionary, snapshot, toManyRelationshipKeys, toOneRelationshipKeys, updateFromSnapshot, userPresentableDescription, willChange
takeValuesFromDictionary, takeValuesFromDictionaryWithMapping, valuesForKeys, valuesForKeysWithMapping
takeValueForKeyPath, valueForKeyPath
storedValueForKey, takeStoredValueForKey
takeValueForKey, valueForKey
handleQueryWithUnboundKey, handleTakeValueForUnboundKey, unableToSetNullForKey
addObjectToBothSidesOfRelationshipWithKey, addObjectToPropertyWithKey, removeObjectFromBothSidesOfRelationshipWithKey, removeObjectFromPropertyWithKey
validateClientUpdate, validateForDelete, validateForInsert, validateForSave, validateForUpdate
static final org.slf4j.Logger copyLogger
static final String ERXCOPYABLE_KEY
ERXCopyable
" which is the exact String that must be used as the
key in the Entity's EOModel UserInfo dictionary to designate it as
implementing ERXCopyable
interface.static final String COPY_TYPE_KEY
ERXCopyable.CopyType
" which is the exact String that must be
used as the key in an Attribute's or Relationship's EOModel UserInfo
dictionary to specify the way the property should be copied by
ERXCopyable
.T copy()
copy(NSMutableDictionary)
that
creates the dictionary for you. You can use this to start the copying of
a graph if you have no need to reference the dictionary.T copy(NSMutableDictionary<com.webobjects.eocontrol.EOGlobalID,ERXCopyable<?>> copiedObjects)
copiedObjects
, then that copy is returned instead of making a new
copy. This allows complex graphs of objects, including those with cycles,
to be copied without producing duplicate objects. The graph of copied
objects will be the same regardless of where copy is started with two
exceptions: if it is started on a reference copied object or if a
reference copied object is the only path between two disconnected parts
of the graph. In these cases the reference copied object prevents the
copy from following the graph further.copiedObjects
- the copied objects keyed on the EOGlobalID
of the
object the copy was made from.T duplicate(NSMutableDictionary<com.webobjects.eocontrol.EOGlobalID,ERXCopyable<?>> copiedObjects)
ERXCopyable
should implement
this to produce the actual copy by an appropriate mechanism (reference,
shallow, deep, or custom).copiedObjects
- the copied objects keyed on the EOGlobalID
of the
object the copy was made from.Copyright © 2002 – 2020 Project Wonder.