public abstract class StructuredCoder<T> extends Coder<T>
Coder
that defines equality, hashing, and printing
via the class name and recursively using getComponents()
.
A StructuredCoder
should be defined purely in terms of its component coders, and
contain no additional configuration.
To extend StructuredCoder
, override the following methods as appropriate:
getComponents()
: the default implementation returns Coder.getCoderArguments()
.
Coder.getEncodedElementByteSize(T)
and Coder.isRegisterByteSizeObserverCheap(T)
: the
default implementation encodes values to bytes and counts the bytes, which is considered
expensive. The default element byte size observer uses the value returned by Coder.getEncodedElementByteSize(T)
.
Coder.Context, Coder.NonDeterministicException
Modifier | Constructor and Description |
---|---|
protected |
StructuredCoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(@Nullable java.lang.Object o) |
java.util.List<? extends Coder<?>> |
getComponents()
|
int |
hashCode() |
java.lang.String |
toString() |
consistentWithEquals, decode, decode, encode, encode, getCoderArguments, getEncodedElementByteSize, getEncodedTypeDescriptor, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, verifyDeterministic, verifyDeterministic, verifyDeterministic
public java.util.List<? extends Coder<?>> getComponents()
Coders
that are components of this Coder
.
The default components will be equal to the value returned by Coder.getCoderArguments()
.
public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
true
if the two StructuredCoder
instances have the same class and equal
components.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object