Class ImmutableDataObject
- java.lang.Object
-
- com.opencloud.util.ImmutableDataObject
-
- All Implemented Interfaces:
DataObject,Immutable,Serializable
- Direct Known Subclasses:
AbstractInfoObject,ASN1Null,BooleanDataObject,EncodedExternal,ObjectID,TcapApplicationContext,TcapError,TcapOperation
public abstract class ImmutableDataObject extends Object implements DataObject, Immutable
Simple base implementation of an immutable DataObject for cases where there's no other inheritance structure to get in the way.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ImmutableDataObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Perform a deep copy of this object.booleanisReadOnly()Check if this object has been set read-only.voidsetReadOnly()Set this object to be "read-only".
-
-
-
Method Detail
-
clone
public Object clone()
Description copied from interface:DataObjectPerform a deep copy of this object. Read-only state of the object is not copied; the new object will be read-write by default.Inherently immutable objects may optionally return the same object without modification from clone(), rather than constructing a new instance.
- Specified by:
clonein interfaceDataObject- Overrides:
clonein classObject- Returns:
- a new object that is a deep copy of this object; for immutable objects, the same object may optionally be returned.
-
setReadOnly
public void setReadOnly()
Description copied from interface:DataObjectSet this object to be "read-only". Any subsequent attempt to modify this object will throw IllegalStateException. Once an object has been made read-only, it cannot be later set to read-write - this is a "one-way" operation.Note that a read-only object is not necessarily immutable; if reference types are returned from accessors, then callers could theoretically mutate those objects even if the top-level object is marked as read-only. The ability to make objects read-only is intended to catch programming errors (e.g. attempting to modify a data object passed as part of a SLEE event), not to provide an absolute guarantee of immutability.
Calling setReadOnly() on an object that is already read-only is a no-op.
Some DataObject implementations may be inherently immutable. In those cases, they are considered always read-only.
- Specified by:
setReadOnlyin interfaceDataObject
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:DataObjectCheck if this object has been set read-only.- Specified by:
isReadOnlyin interfaceDataObject- Returns:
- true if the object is read-only or inherently immutable
- See Also:
DataObject.setReadOnly()
-
-