T
- the type of the elements of the Lists being transcodedpublic class ListCoder<T> extends IterableLikeCoder<T,java.util.List<T>>
Coder.Context, Coder.NonDeterministicException
Modifier | Constructor and Description |
---|---|
protected |
ListCoder(Coder<T> elemCoder) |
Modifier and Type | Method and Description |
---|---|
boolean |
consistentWithEquals()
|
protected java.util.List<T> |
decodeToIterable(java.util.List<T> decodedElements)
Builds an instance of
IterableT , this coder's associated Iterable -like subtype,
from a list of decoded elements. |
TypeDescriptor<java.util.List<T>> |
getEncodedTypeDescriptor()
Returns the
TypeDescriptor for the type encoded. |
static <T> ListCoder<T> |
of(Coder<T> elemCoder) |
java.lang.Object |
structuralValue(java.util.List<T> values)
Returns an object with an
Object.equals() method that represents structural equality on
the argument. |
void |
verifyDeterministic()
List sizes are always known, so ListIterable may be deterministic while the general
IterableLikeCoder is not.
|
decode, decodeToIterable, encode, getCoderArguments, getElemCoder, isRegisterByteSizeObserverCheap, registerByteSizeObserver
equals, getComponents, hashCode, toString
decode, encode, getEncodedElementByteSize, verifyDeterministic, verifyDeterministic
protected final java.util.List<T> decodeToIterable(java.util.List<T> decodedElements)
IterableLikeCoder
IterableT
, this coder's associated Iterable
-like subtype,
from a list of decoded elements.
Override IterableLikeCoder.decodeToIterable(List, long, InputStream)
if you need access to the
terminator value and the InputStream
.
decodeToIterable
in class IterableLikeCoder<T,java.util.List<T>>
public boolean consistentWithEquals()
Coder
true
if this Coder
is injective with respect to Object.equals(java.lang.Object)
.
Whenever the encoded bytes of two values are equal, then the original values are equal
according to Objects.equals()
. Note that this is well-defined for null
.
This condition is most notably false for arrays. More generally, this condition is false
whenever equals()
compares object identity, rather than performing a
semantic/structural comparison.
By default, returns false.
consistentWithEquals
in class Coder<java.util.List<T>>
public java.lang.Object structuralValue(java.util.List<T> values)
Coder
Object.equals()
method that represents structural equality on
the argument.
For any two values x
and y
of type T
, if their encoded bytes are the
same, then it must be the case that structuralValue(x).equals(structuralValue(y))
.
Most notably:
null
should be a proper object with an
equals()
method, even if the input value is null
.
See also Coder.consistentWithEquals()
.
By default, if this coder is Coder.consistentWithEquals()
, and the value is not null,
returns the provided object. Otherwise, encodes the value into a byte[]
, and returns an
object that performs array equality on the encoded bytes.
structuralValue
in class Coder<java.util.List<T>>
public void verifyDeterministic() throws Coder.NonDeterministicException
verifyDeterministic
in class IterableLikeCoder<T,java.util.List<T>>
Coder.NonDeterministicException
- if this coder is not deterministic.public TypeDescriptor<java.util.List<T>> getEncodedTypeDescriptor()
Coder
TypeDescriptor
for the type encoded.getEncodedTypeDescriptor
in class Coder<java.util.List<T>>