org.electrocodeogram.cpc.core.api.data.special
Interface ICloneObjectExtensionMultiStatefulObject
- All Superinterfaces:
- java.lang.Cloneable, ICloneDataElement, ICloneObjectExtension, ICloneObjectExtensionStatefulObject, IStatefulObject, java.io.Serializable
- All Known Subinterfaces:
- ICloneObjectExtensionLazyMultiStatefulObject
public interface ICloneObjectExtensionMultiStatefulObject
- extends ICloneObjectExtensionStatefulObject
Extension interface for ICloneObjectExtensionStatefulObject
for
ICloneObjectExtension
implementations.
This interface is meant used for ICloneObjectExtension
s which need to persist a large,
fluctuating number of fields.
The ICloneObjectExtensionStatefulObject
API requires you to map your internal state to a
single Map object with a predefined, unchanging number of values.
This does offer you any good way of persisting lists with complex content of arbitrary length.
If you just want to persist a simple object with a fixed number of fields, please refer to the
ICloneObjectExtensionStatefulObject
API.
An object of this type is persisted/restored in two steps:
- The regular part of the object is persisted/restored like normal
ICloneObjectExtensionStatefulObject
object.
- The all list parts of the object are persisted/restored.
There can be an arbitrary but fixed number of different sub-element types. The methods of this interface
always return lists or elements or of lists. Each entry in the top most list corresponds to one sub-element type.
The order of sub-element types must be the same for all methods.
I.e. if you have an extension X which keeps a couple of fields as well as two lists, one holding elements of type A
the other of type B. To persist X you would implement ICloneObjectExtensionMultiStatefulObject
and use the
normal ICloneObjectExtensionStatefulObject
API for the persistence of all the fields of X, except the lists.
All methods of this API would then return/take a two element top most list, the first element corresponding to persistence
data for A and the second element corresponding to persistence data for B.
If you only have just one sub-element type, just return a list with a single entry, as top most list.
If you don't have any sub-element, you should look at ICloneObjectExtensionStatefulObject
instead.
- Author:
- vw
- See Also:
ICloneObjectExtensionStatefulObject
,
IStatefulObject
,
ICloneObjectExtension
DELETION_MARK_IDENTIFIER
static final java.lang.String DELETION_MARK_IDENTIFIER
- The
getMultiState()
key to use to indicate whether an
ICloneObjectExtensionMultiStatefulObject
sub-element was deleted.
The type for this key is Boolean.
The key is optional, if not present, the default value is false.
IMPORTANT: this key must not be used for anything else. It must also not be
part of the getMultiStateTypes()
maps.
- See Also:
- Constant Field Values
getMultiPersistenceClassIdentifier
java.util.List<java.lang.String> getMultiPersistenceClassIdentifier()
- A list of PERSISTENCE_CLASS_IDENTIFIER for the sub-objects.
- Returns:
- a list of PERSISTENCE_CLASS_IDENTIFIER for the sub-objects, never null.
- See Also:
IStatefulObject.getPersistenceClassIdentifier()
getMultiPersistenceObjectIdentifier
java.util.List<java.lang.String> getMultiPersistenceObjectIdentifier()
- A list of PERSISTENCE_OBJECT_IDENTIFIER for the sub-objects.
The corresponding key in the state map has to be a unique value.
- Returns:
- a list of PERSISTENCE_OBJECT_IDENTIFIER for the sub-objects, never null.
- See Also:
IStatefulObject.getPersistenceObjectIdentifier()
getMultiState
java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.Comparable<? extends java.lang.Object>>>> getMultiState()
- Retrieves a list of lists of
IStatefulObject.getState()
mappings for each sub-element of this
extension.
The elements of the topmost list must be sorted in ascending order according to the key returned by
getMultiPersistenceObjectIdentifier()
.
The "parent_uuid" key needs to be present in each mapping.
The list also needs to contain deleted sub-elements. For those the DELETION_MARK_IDENTIFIER
key in the state map should be set to true.
- Returns:
- list of
IStatefulObject.getState()
mappings, never null. - See Also:
IStatefulObject.getState()
setMultiState
void setMultiState(java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.Comparable<? extends java.lang.Object>>>> states)
- Sets the internal state of this object and all its sub-objects via the given
list of lists of
IStatefulObject.setState(Map)
mappings.
If the parameter is NULL, all sub-element data for this extension object is cleared.
This typically happens when all clone data for a file is persisted.
- Parameters:
states
- list of IStatefulObject.setState(Map)
mappings, may be NULL.- See Also:
IStatefulObject.setState(Map)
getMultiStateTypes
java.util.List<java.util.Map<java.lang.String,java.lang.Class<? extends java.lang.Object>>> getMultiStateTypes()
- Retrieves the
IStatefulObject.getStateTypes()
mapping for the different sub-element types.
The "parent_uuid" key needs to be present in all mappings.
- Returns:
IStatefulObject.getStateTypes()
mapping for sub-element type.- See Also:
IStatefulObject.getStateTypes()
purgeDeletedEntries
void purgeDeletedEntries()
- Indicates that all deleted sub-elements can be purged.
After this method was called, getMultiState()
should
contain only non-deleted sub-entries.
This method is typically called by the store provider once this ICloneObjectExtensionStatefulObject
was successfully persisted.