org.electrocodeogram.cpc.core.api.data.special
Interface IStatefulObject

All Known Subinterfaces:
ICloneFileInterfaces, ICloneGroupInterfaces, ICloneInterfaces, ICloneObjectExtensionLazyMultiStatefulObject, ICloneObjectExtensionMultiStatefulObject, ICloneObjectExtensionStatefulObject, ICloneObjectInterfaces, IMultiKeyStatefulObject, IStoreCloneObject
All Known Implementing Classes:
CloneDiff, CompositCloneDiff

public interface IStatefulObject

Special sub-interface for all objects which are to be persisted by an IStoreProvider. The methods are used to extract and restore the internal state of an object.

Author:
vw
See Also:
IStoreProvider, ICloneObjectExtensionStatefulObject

Method Summary
 java.lang.String getPersistenceClassIdentifier()
          Returns a string which uniquely identifies the object type.
 java.lang.String getPersistenceObjectIdentifier()
          Returns a key which corresponds to an entry in the state Map returned by getState() which uniquely identifies an object instance.
 java.util.Map<java.lang.String,java.lang.Comparable<? extends java.lang.Object>> getState()
          Returns a map which fully describes the internal state of this object.
 java.util.Map<java.lang.String,java.lang.Class<? extends java.lang.Object>> getStateTypes()
          Returns a list of all keys which are needed to persist this objects internal state.
 void setState(java.util.Map<java.lang.String,java.lang.Comparable<? extends java.lang.Object>> state)
          Restores the internal state of this object to the state which was extracted by means of getState() earlier.
 

Method Detail

getPersistenceClassIdentifier

java.lang.String getPersistenceClassIdentifier()
Returns a string which uniquely identifies the object type.

For the default ICloneObject sub interfaces the return values must equal the PERSISTENCE_CLASS_IDENTIFIER constant defined in the interface.

3rd party clone objects can define their own persistence identifiers.
Allowed are only letters, numbers and the underscore. Furthermore an identifier needs to contain at least one letter, may not begin with an underscore and may not contain multiple consecutive underscores.

A typical store provider will use this method to derive directory/file or table names.

Returns:
unique identifier for the object type, never null.

getPersistenceObjectIdentifier

java.lang.String getPersistenceObjectIdentifier()
Returns a key which corresponds to an entry in the state Map returned by getState() which uniquely identifies an object instance.

For the default ICloneObject sub interfaces the return values must equal the PERSISTENCE_OBJECT_IDENTIFIER constant defined in the ICloneObject interface.

By default this is uuid.

3rd party clone objects can define their own persistence identifiers.
Allowed are only letters, numbers and the underscore. Furthermore an identifier needs to contain at least one letter, may not begin with an underscore and may not contain multiple consecutive underscores.

A typical store provider will use this method to derive file names, internal id structure names or table primary keys.

IMPORTANT: the corresponding value in getState() must not be changed at any point.
The unique identifiers of all stateful objects must remain unchanged during their entire lifetime.

Returns:
key for state Map which yields a unique identifier for an object instance, never null. Will usually return "uuid".
See Also:
getState()

getState

java.util.Map<java.lang.String,java.lang.Comparable<? extends java.lang.Object>> getState()
Returns a map which fully describes the internal state of this object. The map is persisted by the IStoreProvider and the setState() method is used to restore a persisted state.

In case of an ICloneObject, the map does not include any data for ICloneObjectExtension which are stored under the object.

The values in the map are restricted to the following object types:

The keys in the map should correspond to the following schema: IMPORTANT NOTEs:

Returns:
a map describing the internal state of this object, never null.
See Also:
setState(Map)

setState

void setState(java.util.Map<java.lang.String,java.lang.Comparable<? extends java.lang.Object>> state)
Restores the internal state of this object to the state which was extracted by means of getState() earlier.

For a description of the internal structure of the map, see getState().

Parameters:
state - a map describing the internal state of this object, never null
See Also:
getState()

getStateTypes

java.util.Map<java.lang.String,java.lang.Class<? extends java.lang.Object>> getStateTypes()
Returns a list of all keys which are needed to persist this objects internal state. The values in the returned Map correspond to the classes of the values which will be used in the Map returned by getState().

I.e. if getState() will return a Map which contains the key "uuid" with the value "jda83ds-..." then this Map contains the key "uuid" with the value String.class.

Returns:
map which contains all keys and their data types, never null
See Also:
getState()