Top Description Fields Constructors Methods
com.google.protobuf

pack-priv abstract Class AbstractProtobufList<E>

extends AbstractList<E>
implements Internal.ProtobufList<E>
Class Inheritance
All Implemented Interfaces
com.google.protobuf.Internal.ProtobufList, java.util.RandomAccess, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
com.google.protobuf.BooleanArrayList, com.google.protobuf.ProtobufArrayList, com.google.protobuf.FloatArrayList, com.google.protobuf.IntArrayList, com.google.protobuf.LazyStringArrayList, com.google.protobuf.LongArrayList, com.google.protobuf.DoubleArrayList
Imports
com.google.protobuf.Internal.ProtobufList, java.util.AbstractList, .Collection, .List, .RandomAccess

An abstract implementation of 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

Modifier and TypeField and Description
protected static final int
private boolean
isMutable

Whether or not this list is modifiable.

Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractProtobufList()

Constructs a mutable list by default.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(E
element to be appended to this list
e
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this list (optional operation).
public void
add(int
index at which the specified element is to be inserted
index
,
E
element to be inserted
element
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).
public boolean
addAll(Collection<? extends E>
collection containing elements to be added to this list
c
)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

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).
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.util.AbstractList.addAll.

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
public void
clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Removes all of the elements from this list (optional operation).
protected void
ensureIsMutable()

Throws an UnsupportedOperationException if the list is immutable.

public boolean
equals(Object
the object to be compared for equality with this list
o
)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified object with this list for equality.
public int
hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Returns the hash code value for this list.
public boolean
isModifiable()

Implements com.google.protobuf.Internal.ProtobufList.isModifiable.

Returns whether this list can be modified via the publicly accessible List methods.
public final void
public E
remove(int
the index of the element to be removed
index
)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).
public boolean
remove(Object
element to be removed from this list, if present
o
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).
public boolean
removeAll(Collection<?>
collection containing elements to be removed from this list
c
)

Overrides java.util.AbstractCollection.removeAll.

Implements java.util.List.removeAll, java.util.Collection.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).
public boolean
retainAll(Collection<?>
collection containing elements to be retained in this list
c
)

Overrides java.util.AbstractCollection.retainAll.

Implements java.util.List.retainAll, java.util.Collection.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).
public E
set(int
index of the element to replace
index
,
E
element to be stored at the specified position
element
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
Inherited from java.util.AbstractList:
getindexOfiteratorlastIndexOflistIteratorlistIteratorremoveRangesubList

Field Detail

DEFAULT_CAPACITYback to summary
protected static final int DEFAULT_CAPACITY
isMutableback to summary
private boolean isMutable

Whether or not this list is modifiable.

Constructor Detail

AbstractProtobufListback to summary
pack-priv AbstractProtobufList()

Constructs a mutable list by default.

Method Detail

addback to summary
public boolean add(E e)

Overrides java.util.AbstractList.add.

Implements java.util.List.add, java.util.Collection.add.

Doc from java.util.List.add.

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.

Parameters
e:E

element to be appended to this list

Returns:boolean

true (as specified by Collection#add)

Annotations
@Override
addback to summary
public void add(int index, E element)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Doc from java.util.List.add.

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).

Parameters
index:int

index at which the specified element is to be inserted

element:E

element to be inserted

Annotations
@Override
addAllback to summary
public boolean addAll(Collection<? extends E> c)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Doc from java.util.List.addAll.

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.)

Parameters
c:Collection<? extends E>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

Annotations
@Override
addAllback to summary
public boolean addAll(int index, Collection<? extends E> c)

Overrides java.util.AbstractList.addAll.

Implements java.util.List.addAll.

Doc from java.util.List.addAll.

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.)

Parameters
index:int

index at which to insert the first element from the specified collection

c:Collection<? extends E>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

Annotations
@Override
clearback to summary
public void clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Doc from java.util.List.clear.

Removes all of the elements from this list (optional operation). The list will be empty after this call returns.

Annotations
@Override
ensureIsMutableback to summary
protected void ensureIsMutable()

Throws an UnsupportedOperationException if the list is immutable. Subclasses are responsible for invoking this method on mutate operations.

equalsback to summary
public boolean equals(Object o)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Doc from java.util.List.equals.

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if Objects.equals(e1, e2).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.

Parameters
o:Object

the object to be compared for equality with this list

Returns:boolean

true if the specified object is equal to this list

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Doc from java.util.List.hashCode.

Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:

int hashCode = 1;
    for (E e : list)
        hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
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.
Returns:int

the hash code value for this list

Annotations
@Override
isModifiableback to summary
public boolean isModifiable()

Implements com.google.protobuf.Internal.ProtobufList.isModifiable.

Doc from com.google.protobuf.Internal.ProtobufList.isModifiable.

Returns whether this list can be modified via the publicly accessible List methods.

Annotations
@Override
makeImmutableback to summary
public final void makeImmutable()

Implements com.google.protobuf.Internal.ProtobufList.makeImmutable.

Doc from com.google.protobuf.Internal.ProtobufList.makeImmutable.

Makes this list immutable. All subsequent modifications will throw an UnsupportedOperationException.

Annotations
@Override
removeback to summary
public E remove(int index)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Doc from java.util.List.remove.

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.

Parameters
index:int

the index of the element to be removed

Returns:E

the element previously at the specified position

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Doc from java.util.List.remove.

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 i such that Objects.equals(o, get(i)) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).

Parameters
o:Object

element to be removed from this list, if present

Returns:boolean

true if this list contained the specified element

Annotations
@Override
removeAllback to summary
public boolean removeAll(Collection<?> c)

Overrides java.util.AbstractCollection.removeAll.

Implements java.util.List.removeAll, java.util.Collection.removeAll.

Doc from java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Parameters
c:Collection<?>

collection containing elements to be removed from this list

Returns:boolean

true if this list changed as a result of the call

Annotations
@Override
retainAllback to summary
public boolean retainAll(Collection<?> c)

Overrides java.util.AbstractCollection.retainAll.

Implements java.util.List.retainAll, java.util.Collection.retainAll.

Doc from java.util.List.retainAll.

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.

Parameters
c:Collection<?>

collection containing elements to be retained in this list

Returns:boolean

true if this list changed as a result of the call

Annotations
@Override
setback to summary
public E set(int index, E element)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Doc from java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

index of the element to replace

element:E

element to be stored at the specified position

Returns:E

the element previously at the specified position

Annotations
@Override