public class UnmodifiableLazyStringList extends AbstractList<String> implements LazyStringList, RandomAccess
LazyStringList
that wraps another
LazyStringList
such that it cannot be modified via the wrapper.modCount
Constructor and Description |
---|
UnmodifiableLazyStringList(LazyStringList list) |
Modifier and Type | Method and Description |
---|---|
void |
add(ByteString element)
Appends the specified element to the end of this list (optional operation).
|
String |
get(int index)
Returns the element at the specified position in this list.
|
ByteString |
getByteString(int index)
Returns the element at the specified position in this list as a ByteString.
|
List<?> |
getUnderlyingElements()
Returns an unmodifiable List of the underlying elements, each of which is either a
String or its
equivalent UTF-8 encoded ByteString or byte[]. |
Iterator<String> |
iterator()
Returns an iterator over the elements in this list in proper sequence.
|
ListIterator<String> |
listIterator(int index)
Returns a list iterator over the elements in this list (in proper sequence), starting at the
specified position in the list.
|
int |
size()
Returns the number of elements in this collection.
|
add, add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
add, addAllByteArray, addAllByteString, asByteArrayList, getByteArray, getRaw, getUnmodifiableView, mergeFrom, set, set
asByteStringList
public UnmodifiableLazyStringList(LazyStringList list)
public void add(ByteString element)
LazyStringList
add
in interface LazyStringList
element
- element to be appended to this listpublic String get(int index)
AbstractList
public ByteString getByteString(int index)
LazyStringList
getByteString
in interface LazyStringList
index
- index of the element to returnpublic List<?> getUnderlyingElements()
LazyStringList
String
or its
equivalent UTF-8 encoded ByteString
or byte[]. It is an error for the caller to modify the returned List,
and attempting to do so will result in an UnsupportedOperationException
.getUnderlyingElements
in interface LazyStringList
public Iterator<String> iterator()
AbstractList
This implementation returns a straightforward implementation of the iterator interface, relying
on the backing list's size()
, get(int)
, and remove(int)
methods.
Note that the iterator returned by this method will throw an
UnsupportedOperationException
in response to its remove
method unless the list's
remove(int)
method is overridden.
This implementation can be made to throw runtime exceptions in the face of concurrent
modification, as described in the specification for the (protected) AbstractList.modCount
field.
public ListIterator<String> listIterator(int index)
AbstractList
next
. An initial call to
previous
would return the element with the specified index minus
one.
This implementation returns a straightforward implementation of the ListIterator
interface that extends the implementation of the Iterator
interface returned by the
iterator()
method. The ListIterator
implementation relies on the backing list's
get(int)
, set(int, E)
, add(int, E)
and remove(int)
methods.
Note that the list iterator returned by this implementation will throw an
UnsupportedOperationException
in response to its remove
, set
and
add
methods unless the list's remove(int)
, set(int, E)
, and
add(int, E)
methods are overridden.
This implementation can be made to throw runtime exceptions in the face of concurrent
modification, as described in the specification for the (protected) AbstractList.modCount
field.
listIterator
in interface List<String>
listIterator
in class AbstractList<String>
index
- index of the first element to be returned from the list iterator (by a call to
next
)public int size()
AbstractCollection
size
in interface Collection<String>
size
in interface List<String>
size
in class AbstractCollection<String>