Class UnmodifiableLazyStringList

public class UnmodifiableLazyStringList extends AbstractList<String> implements LazyStringList, RandomAccess

An implementation of LazyStringList that wraps another LazyStringList such that it cannot be modified via the wrapper.

Inheritance

Object > java.util.AbstractCollection > AbstractList > UnmodifiableLazyStringList

Constructors

UnmodifiableLazyStringList(LazyStringList list)

public UnmodifiableLazyStringList(LazyStringList list)
Parameter
NameDescription
listLazyStringList

Methods

add(byte[] element)

public void add(byte[] element)

Appends the specified element to the end of this list (optional operation).

Parameter
NameDescription
elementbyte[]

add(ByteString element)

public void add(ByteString element)

Appends the specified element to the end of this list (optional operation).

Parameter
NameDescription
elementByteString

addAllByteArray(Collection<byte[]> element)

public boolean addAllByteArray(Collection<byte[]> element)

Appends all elements in the specified byte[] collection to the end of this list.

Parameter
NameDescription
elementCollection<byte[]>
Returns
TypeDescription
boolean

addAllByteString(Collection<? extends ByteString> element)

public boolean addAllByteString(Collection<? extends ByteString> element)

Appends all elements in the specified ByteString collection to the end of this list.

Parameter
NameDescription
elementCollection<? extends com.google.protobuf.ByteString>
Returns
TypeDescription
boolean

asByteArrayList()

public List<byte[]> asByteArrayList()

Returns a mutable view of this list. Changes to the view will be made into the original list. This method is used in mutable API only.

Returns
TypeDescription
List<byte[]>

asByteStringList()

public List<ByteString> asByteStringList()

Returns a view of the data as a list of ByteStrings.

Returns
TypeDescription
List<ByteString>

get(int index)

public String get(int index)
Parameter
NameDescription
indexint
Returns
TypeDescription
String
Overrides

getByteArray(int index)

public byte[] getByteArray(int index)

Returns the element at the specified position in this list as byte[].

Parameter
NameDescription
indexint
Returns
TypeDescription
byte[]

getByteString(int index)

public ByteString getByteString(int index)

Returns the element at the specified position in this list as a ByteString.

Parameter
NameDescription
indexint
Returns
TypeDescription
ByteString

getRaw(int index)

public Object getRaw(int index)

Returns the element at the specified position in this list as an Object that will either be a String or a ByteString.

Parameter
NameDescription
indexint
Returns
TypeDescription
Object

getUnderlyingElements()

public 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[]. It is an error for the caller to modify the returned List, and attempting to do so will result in an UnsupportedOperationException.

Returns
TypeDescription
List<?>

getUnmodifiableView()

public LazyStringList getUnmodifiableView()

Returns an unmodifiable view of the list.

Returns
TypeDescription
LazyStringList

iterator()

public Iterator<String> iterator()
Returns
TypeDescription
Iterator<String>
Overrides

listIterator(int index)

public ListIterator<String> listIterator(int index)
Parameter
NameDescription
indexint
Returns
TypeDescription
ListIterator<String>
Overrides

mergeFrom(LazyStringList other)

public void mergeFrom(LazyStringList other)

Merges all elements from another LazyStringList into this one. This method differs from #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.

Parameter
NameDescription
otherLazyStringList

set(int index, byte[] element)

public void set(int index, byte[] element)

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

Parameters
NameDescription
indexint
elementbyte[]

set(int index, ByteString element)

public void set(int index, ByteString element)

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

Parameters
NameDescription
indexint
elementByteString

size()

public int size()
Returns
TypeDescription
int
Overrides