abstract class AbstractProtobufList<E> extends java.util.AbstractList<E> implements Internal.ProtobufList<E>
Internal.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 int |
DEFAULT_CAPACITY |
private boolean |
isMutable
Whether or not this list is modifiable.
|
Constructor and Description |
---|
AbstractProtobufList()
Constructs a mutable list by default.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
void |
add(int index,
E element) |
boolean |
addAll(java.util.Collection<? extends E> c) |
boolean |
addAll(int index,
java.util.Collection<? extends E> c) |
void |
clear() |
protected void |
ensureIsMutable()
Throws an
UnsupportedOperationException if the list is immutable. |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
isModifiable()
Returns whether this list can be modified via the publicly accessible
List methods. |
void |
makeImmutable()
Makes this list immutable.
|
E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
E |
set(int index,
E element) |
get, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
contains, containsAll, isEmpty, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
mutableCopyWithCapacity
protected static final int DEFAULT_CAPACITY
private boolean isMutable
AbstractProtobufList()
public boolean equals(java.lang.Object o)
public int hashCode()
public boolean add(E e)
public void add(int index, E element)
public boolean addAll(java.util.Collection<? extends E> c)
public boolean addAll(int index, java.util.Collection<? extends E> c)
public void clear()
public boolean isModifiable()
Internal.ProtobufList
List
methods.isModifiable
in interface Internal.ProtobufList<E>
public final void makeImmutable()
Internal.ProtobufList
UnsupportedOperationException
.makeImmutable
in interface Internal.ProtobufList<E>
public E remove(int index)
public boolean remove(java.lang.Object o)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
protected void ensureIsMutable()
UnsupportedOperationException
if the list is immutable. Subclasses are
responsible for invoking this method on mutate operations.