org.electrocodeogram.cpc.core.api.data
Interface ICloneObject

All Superinterfaces:
java.lang.Cloneable, org.eclipse.core.runtime.IAdaptable, ICloneDataElement, java.io.Serializable
All Known Subinterfaces:
IClone, ICloneFile, ICloneFileInterfaces, ICloneGroup, ICloneGroupInterfaces, ICloneInterfaces, ICloneObjectInterfaces, ICreatorClone, ICreatorCloneFile, IRemoteStoreCloneFile, IStoreCloneObject

public interface ICloneObject
extends ICloneDataElement, org.eclipse.core.runtime.IAdaptable, java.io.Serializable, java.lang.Cloneable

Base interface for all CPC Data Objects.

Any implementation needs to implement ICloneObjectInterfaces. Implementing only ICloneObject is not enough!

This interface lists all methods which are available to all CPC plugins and 3rd party contributions.

Additional methods are defined by more specific sub-interfaces (in the *.api.data.special package) which belong to individual CPC plugins and are to be considered private.
Any CPC plugin other than the one designated in the sub-interface API must not access such methods.
This does not apply to the main sub-interfaces in the *.api.data package.

General Considerations valid for all types of CPC Data Objects:

Author:
vw
See Also:
ICloneObjectInterfaces, IAdaptable, Serializable, Cloneable

Field Summary
static java.lang.String PERSISTENCE_OBJECT_IDENTIFIER
          IStatefulObject persistence object identifier, value: "uuid"
 
Method Summary
 void addExtension(ICloneObjectExtension extension)
          Adds an ICloneObjectExtension to this clone object.
 java.lang.Object clone()
          All implementations must be cloneable.
 boolean equals(java.lang.Object obj)
          Equality based on uuid.
 boolean equalsAll(ICloneObject otherCloneObject)
          Checks not only the uuid but ALL data fields for equality.
 ICloneObjectExtension getExtension(java.lang.Class<? extends ICloneObjectExtension> extensionClass)
          Retrieves an ICloneObjectExtension which has been added to this clone object.
 java.util.List<ICloneObjectExtension> getExtensions()
          Retrieves a list of all currently added ICloneObjectExtensions for this clone object which have not been deleted.
 java.lang.String getUuid()
          Retrieves the uuid which uniquely identifies this object.
 boolean hasExtensions()
          Cached boolean value which indicates whether there is currently any ICloneObjectExtension added to this clone object.
 int hashCode()
          HashCode based on uuid.
 boolean isMarked()
          Checks whether this clone object has been marked.
 void removeExtension(java.lang.Class<? extends ICloneObjectExtension> extensionClass)
          Removes any ICloneObjectExtension of the given type from this ICloneObject.
 void removeExtension(ICloneObjectExtension extension)
          Removes any ICloneObjectExtension which matches the ICloneObjectExtension.getExtensionInterfaceClass() value of the given extension from this ICloneObject.
 void setMarked(boolean marked)
          Marks or unmarks a clone object.
 java.lang.String toString()
          All implementations should provide a meaningful toString() method for debugging purposes.
 
Methods inherited from interface org.electrocodeogram.cpc.core.api.data.ICloneDataElement
isSealed, seal
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

PERSISTENCE_OBJECT_IDENTIFIER

static final java.lang.String PERSISTENCE_OBJECT_IDENTIFIER
IStatefulObject persistence object identifier, value: "uuid"

See Also:
Constant Field Values
Method Detail

getUuid

java.lang.String getUuid()
Retrieves the uuid which uniquely identifies this object.

This value has to be initialised during the construction of an object.

Returns:
unique identifier of this object, never null.

isMarked

boolean isMarked()
Checks whether this clone object has been marked.

A typical use for marks is to pass info on some kind of selection of clone objects from a list between method calls without having to create an additional list or having to add an ICloneObjectExtension.

Marks are not persisted.

NOTE: Marks have no meaning outside of the module which set them. They exist only due to performance considerations. If you need to store some data for a clone object which will be handled by other modules, you should use getExtension(Class) instead.
Whenever a clone object leaves your module, you should consider all marks to be lost/corrupted.

Returns:
true if this instance has been marked.

setMarked

void setMarked(boolean marked)
Marks or unmarks a clone object.

Marks are not persisted.

Be sure to read the limitations for the usage of marks, see: isMarked()

Parameters:
marked - whether this instance should be marked or not.
See Also:
isMarked()

hasExtensions

boolean hasExtensions()
Cached boolean value which indicates whether there is currently any ICloneObjectExtension added to this clone object.
The return value will be false if there is no non-deleted extension present. Deleted extensions are not taken into account.
This values is persisted as part of the ICloneObject.

Returns:
true if there is at least one extension for this object.

getExtension

ICloneObjectExtension getExtension(java.lang.Class<? extends ICloneObjectExtension> extensionClass)
Retrieves an ICloneObjectExtension which has been added to this clone object. If no extension of this type has been added, null is returned.
A deleted extension will not be returned.

Parameters:
extensionClass - the extension type to retrieve, never null
Returns:
the extension in question or NULL if no such extension has been added
See Also:
ICloneObjectExtension

getExtensions

java.util.List<ICloneObjectExtension> getExtensions()
Retrieves a list of all currently added ICloneObjectExtensions for this clone object which have not been deleted.

Returns:
list of non-deleted ICloneObjectExtensions, never null.
See Also:
ICloneObjectExtension

addExtension

void addExtension(ICloneObjectExtension extension)
Adds an ICloneObjectExtension to this clone object.
The ICloneObjectExtension will be registered under the class returned by its ICloneObjectExtension.getExtensionInterfaceClass() method.

There can only be one extension of a given type at any time. Adding an extension while another extension of the same type is already registered, will replace the existing extension.

NOTE: in the current implementation stateful extensions will only be persisted for IClone objects.

Parameters:
extension - the extension to add, will replace any existing extension of the same type, never null.
See Also:
ICloneObjectExtension

removeExtension

void removeExtension(java.lang.Class<? extends ICloneObjectExtension> extensionClass)
Removes any ICloneObjectExtension of the given type from this ICloneObject.
The extension is added to the internal deletion registry.

Parameters:
extensionClass - the interface type for which a registered extension should be removed, never null.
See Also:
IStoreCloneObject.getDeletedExtensions(), IStoreCloneObject.purgeDeletedExtensions()

removeExtension

void removeExtension(ICloneObjectExtension extension)
Removes any ICloneObjectExtension which matches the ICloneObjectExtension.getExtensionInterfaceClass() value of the given extension from this ICloneObject.
Convenience method.
This is a short hand for removeExtension(Class).

Parameters:
extension - the ICloneObjectExtension for which any extension of equal type should be removed, never null.
See Also:
removeExtension(Class)

equals

boolean equals(java.lang.Object obj)
Equality based on uuid.

Overrides:
equals in class java.lang.Object

hashCode

int hashCode()
HashCode based on uuid.

Overrides:
hashCode in class java.lang.Object

equalsAll

boolean equalsAll(ICloneObject otherCloneObject)
Checks not only the uuid but ALL data fields for equality.

Parameters:
otherCloneObject - clone object to compare to, may be null, may be same instance
Returns:
true if all fields are equal, false otherwise or if otherCloneObject is null.

clone

java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
All implementations must be cloneable.

Throws:
java.lang.CloneNotSupportedException

toString

java.lang.String toString()
All implementations should provide a meaningful toString() method for debugging purposes.

Overrides:
toString in class java.lang.Object