ProtobufList which manages mutability semantics. All mutate
methods must check if the list is mutable before proceeding. Subclasses must invoke ensureIsMutable() manually when overriding those methods.
This implementation assumes all subclasses are array based, supporting random access.
| Modifier and Type | Field and Description |
|---|---|
| protected static final int | |
| private boolean | isMutable
Whether or not this list is modifiable. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(E
element to be appended to this list e)Overrides java. Implements java. |
| public void | add(int
index at which the specified element is to be inserted index, E element to be inserted element)Overrides java. Implements java. |
| public boolean | addAll(Collection<? extends E>
collection containing elements to be added to this list c)Overrides java. Implements java. |
| public boolean | addAll(int
index at which to insert the first element from the
specified collection index, Collection<? extends E> collection containing elements to be added to this list c)Overrides java. Implements java. |
| public void | clear()
Overrides java. Implements java. |
| protected void | |
| public boolean | equals(Object
the object to be compared for equality with this list o)Overrides java. Implements java. |
| public int | hashCode()
Overrides java. Implements java. |
| public boolean | isModifiable()
Implements com. List methods.
|
| public final void | makeImmutable()
Implements com. |
| public E | remove(int
the index of the element to be removed index)Overrides java. Implements java. |
| public boolean | remove(Object
element to be removed from this list, if present o)Overrides java. Implements java. |
| public boolean | removeAll(Collection<?>
collection containing elements to be removed from this list c)Overrides java. Implements java. |
| public boolean | retainAll(Collection<?>
collection containing elements to be retained in this list c)Overrides java. Implements java. |
| public E | set(int
index of the element to replace index, E element to be stored at the specified position element)Overrides java. Implements java. |
| DEFAULT_CAPACITY | back to summary |
|---|---|
| protected static final int DEFAULT_CAPACITY | |
| isMutable | back to summary |
|---|---|
| private boolean isMutable Whether or not this list is modifiable. | |
| AbstractProtobufList | back to summary |
|---|---|
| pack-priv AbstractProtobufList() Constructs a mutable list by default. | |
| add | back to summary |
|---|---|
| public boolean add(E e) Overrides java. Implements java. Doc from java. Appends the specified element to the end of this list (optional operation). Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.
| |
| add | back to summary |
|---|---|
| public void add(int index, E element) Overrides java. Implements java. Doc from java. Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(Collection<? extends E> c) Overrides java. Implements java. Doc from java. Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(int index, Collection<? extends E> c) Overrides java. Implements java. Doc from java. Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this list (optional operation). The list will be empty after this call returns.
| |
| ensureIsMutable | back to summary |
|---|---|
| protected void ensureIsMutable() Throws an | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two lists,
list1 and list2, as required by the general
contract of Object#hashCode.
| |
| isModifiable | back to summary |
|---|---|
| public boolean isModifiable() Implements com. Doc from com. Returns whether this list can be modified via the publicly accessible
| |
| makeImmutable | back to summary |
|---|---|
| public final void makeImmutable() Implements com. Doc from com. Makes this list immutable. All subsequent modifications will throw an
| |
| remove | back to summary |
|---|---|
| public E remove(int index) Overrides java. Implements java. Doc from java. Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object o) Overrides java. Implements java. Doc from java. Removes the first occurrence of the specified element from this list,
if it is present (optional operation). If this list does not contain
the element, it is unchanged. More formally, removes the element with
the lowest index | |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> c) Overrides java. Implements java. Doc from java. Removes from this list all of its elements that are contained in the specified collection (optional operation).
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> c) Overrides java. Implements java. Doc from java. Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all of its elements that are not contained in the specified collection.
| |
| set | back to summary |
|---|---|
| public E set(int index, E element) Overrides java. Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |