public class ArrayDataObject<T> extends 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.
| Modifier and Type | Field and Description |
|---|---|
protected T[] |
value |
modCount| 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(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.
|
String |
toString()
Returns a printable representation of this.
|
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayprotected 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()
size in interface Collection<T>size in interface List<T>size in class AbstractCollection<T>public ArrayDataObject<T> clone()
DataObjectInherently immutable objects may optionally return the same object without modification from clone(), rather than constructing a new instance.
clone in interface DataObjectclone in class Objectpublic void setReadOnly()
DataObjectNote 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 DataObjectpublic boolean isReadOnly()
DataObjectisReadOnly in interface DataObjectDataObject.setReadOnly()protected void checkModify()
IllegalStateException - if this DataObject is read-onlypublic static ArrayDataObject<?> copyOf(ArrayDataObject<?> from)
from - the object from which to copypublic String toString()
toString in class AbstractCollection<T>public boolean equals(Object obj)
equals in interface Collection<T>equals in interface List<T>equals in class AbstractList<T>obj - other objectpublic int hashCode()
hashCode in interface Collection<T>hashCode in interface List<T>hashCode in class AbstractList<T>