public class ArrayDataObject<T> extends java.util.AbstractList<T> implements DataObject
This implementation assumes that the contained datatype is an opaque type with
no special properties. For arrays of datatypes that implement DataObject,
ArrayOfDataObject
should be used.
Constructor and Description |
---|
ArrayDataObject(T[] value)
Constructs from a given initial array value.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkModify()
Checks whether this DataObject is mutable.
|
ArrayDataObject<T> |
clone()
Perform a deep copy of this object.
|
static ArrayDataObject<?> |
copyOf(ArrayDataObject<?> from)
Creates a new ArrayDataObject, initialising its value from that of the given ArrayDataObject.
|
boolean |
equals(java.lang.Object obj)
Compares some other object to this one for equality by value.
|
T |
get(int index)
Gets the element at the given position in the list.
|
T[] |
getValue()
Gets the array value from this DataObject.
|
int |
hashCode()
Gets a hash code value for this object.
|
boolean |
isReadOnly()
Check if this object has been set read-only.
|
T |
set(int index,
T element)
Sets the element at the given position in the list to the given value.
|
void |
setReadOnly()
Set this object to be "read-only".
|
int |
size()
Gets the size of the list.
|
java.lang.String |
toString()
Returns a printable representation of this.
|
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
protected final T[] value
public ArrayDataObject(T[] value)
value
- array value; must not be null.public T[] getValue()
public T get(int index)
public T set(int index, T element)
public int size()
public ArrayDataObject<T> clone()
DataObject
Inherently immutable objects may optionally return the same object without modification from clone(), rather than constructing a new instance.
clone
in interface DataObject
clone
in class java.lang.Object
public void setReadOnly()
DataObject
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.
setReadOnly
in interface DataObject
public boolean isReadOnly()
DataObject
isReadOnly
in interface DataObject
DataObject.setReadOnly()
protected void checkModify()
java.lang.IllegalStateException
- if this DataObject is read-onlypublic static ArrayDataObject<?> copyOf(ArrayDataObject<?> from)
from
- the object from which to copypublic java.lang.String toString()
toString
in class java.util.AbstractCollection<T>
public boolean equals(java.lang.Object obj)