Package com.google.protobuf
Class AbstractProtobufList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
com.google.protobuf.AbstractProtobufList<E>
- All Implemented Interfaces:
Internal.ProtobufList<E>,Iterable<E>,Collection<E>,List<E>,RandomAccess
- Direct Known Subclasses:
BooleanArrayList,DoubleArrayList,FloatArrayList,IntArrayList,LazyStringArrayList,LongArrayList,ProtobufArrayList
An abstract implementation of
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprivate booleanWhether or not this list is modifiable.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a mutable list by default.AbstractProtobufList(boolean isMutable) Constructs an immutable list for EMPTY lists -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidclear()protected voidThrows anUnsupportedOperationExceptionif the list is immutable.booleaninthashCode()booleanReturns whether this list can be modified via the publicly accessibleListmethods.final voidMakes this list immutable.remove(int index) booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) Methods inherited from class java.util.AbstractList
get, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.google.protobuf.Internal.ProtobufList
mutableCopyWithCapacityMethods inherited from interface java.util.List
contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, size, sort, spliterator, subList, toArray, toArray
-
Field Details
-
DEFAULT_CAPACITY
protected static final int DEFAULT_CAPACITY- See Also:
-
isMutable
private boolean isMutableWhether or not this list is modifiable.
-
-
Constructor Details
-
AbstractProtobufList
AbstractProtobufList()Constructs a mutable list by default. -
AbstractProtobufList
AbstractProtobufList(boolean isMutable) Constructs an immutable list for EMPTY lists
-
-
Method Details
-
equals
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classAbstractList<E>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classAbstractList<E>
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractList<E>
-
add
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractCollection<E>
-
addAll
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classAbstractList<E>
-
isModifiable
public boolean isModifiable()Description copied from interface:Internal.ProtobufListReturns whether this list can be modified via the publicly accessibleListmethods.- Specified by:
isModifiablein interfaceInternal.ProtobufList<E>
-
makeImmutable
public final void makeImmutable()Description copied from interface:Internal.ProtobufListMakes this list immutable. All subsequent modifications will throw anUnsupportedOperationException.- Specified by:
makeImmutablein interfaceInternal.ProtobufList<E>
-
remove
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classAbstractCollection<E>
-
set
-
ensureIsMutable
protected void ensureIsMutable()Throws anUnsupportedOperationExceptionif the list is immutable. Subclasses are responsible for invoking this method on mutate operations.
-