public interface LazyStringList extends ProtocolStringList
List<String> that also provides access to the items of the list as UTF8-encoded ByteString or byte[] objects. This is used by the protocol buffer implementation to support lazily converting bytes parsed over the wire to String objects until needed and also increases the efficiency of serialization if the String was never requested as the ByteString or byte[] is already cached. The ByteString methods are used in immutable API only and byte[] methods used in mutable API only for they use different representations for string/bytes fields.
| Modifier and Type | Method and Description |
|---|---|
void |
add(byte[] element)
Appends the specified element to the end of this list (optional operation).
|
void |
add(ByteString
Appends the specified element to the end of this list (optional operation).
|
boolean |
addAllByteArray(Collection
Appends all elements in the specified byte[] collection to the end of this list.
|
boolean |
addAllByteString(Collection
Appends all elements in the specified ByteString collection to the end of this list.
|
List |
asByteArrayList()
Returns a mutable view of this list.
|
byte[] |
getByteArray(int index)
Returns the element at the specified position in this list as byte[].
|
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[].
|
LazyStringList |
getUnmodifiableView()
Returns an unmodifiable view of the list.
|
void |
mergeFrom(LazyStringList
Merges all elements from another LazyStringList into this one.
|
void |
set(int index, byte[] element)
Replaces the element at the specified position in this list with the specified element (optional operation).
|
void |
set(int index, ByteString
Replaces the element at the specified position in this list with the specified element (optional operation).
|
asByteStringListadd, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArrayparallelStream, removeIf, streamByteStringgetByteString(int index)
index - index of the element to return
IndexOutOfBoundsException - if the index is out of range (
index < 0 || index >= size())
byte[] getByteArray(int index)
index - index of the element to return
IndexOutOfBoundsException - if the index is out of range (
index < 0 || index >= size())
void add(ByteStringelement)
element - element to be appended to this list
UnsupportedOperationException - if the
add operation is not supported by this list
void add(byte[] element)
element - element to be appended to this list
UnsupportedOperationException - if the
add operation is not supported by this list
void set(int index,
ByteString element)
index - index of the element to replace
element - the element to be stored at the specified position
UnsupportedOperationException - if the
set operation is not supported by this list IndexOutOfBoundsException if the index is out of range (
index < 0 || index >= size())
void set(int index,
byte[] element)
index - index of the element to replace
element - the element to be stored at the specified position
UnsupportedOperationException - if the
set operation is not supported by this list IndexOutOfBoundsException if the index is out of range (
index < 0 || index >= size())
boolean addAllByteString(Collection<? extends ByteString > c)
c - collection whose elements are to be added to this list
UnsupportedOperationException - if the
addAllByteString operation is not supported by this list
boolean addAllByteArray(Collection<byte[]> c)
c - collection whose elements are to be added to this list
UnsupportedOperationException - if the
addAllByteArray operation is not supported by this list
List<?> getUnderlyingElements()
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.
void mergeFrom(LazyStringListother)
List.addAll(Collection) on that underlying byte arrays are copied instead of reference shared. Immutable API doesn't need to use this method as byte[] is not used there at all.
List<byte[]> asByteArrayList()
LazyStringListgetUnmodifiableView()