T
- the type of the elements of the setpublic class SetCoder<T> extends IterableLikeCoder<T,java.util.Set<T>>
SetCoder
encodes any Set
using the format of IterableLikeCoder
. The
elements may not be in a deterministic order, depending on the Set
implementation.Coder.Context, Coder.NonDeterministicException
Modifier | Constructor and Description |
---|---|
protected |
SetCoder(Coder<T> elemCoder) |
Modifier and Type | Method and Description |
---|---|
protected java.util.Set<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.Set<T>> |
getEncodedTypeDescriptor()
Returns the
TypeDescriptor for the type encoded. |
static <T> SetCoder<T> |
of(Coder<T> elementCoder)
Produces a
SetCoder with the given elementCoder . |
void |
verifyDeterministic()
Throw
Coder.NonDeterministicException if the coding is not deterministic. |
decode, encode, getCoderArguments, getElemCoder, isRegisterByteSizeObserverCheap, registerByteSizeObserver
equals, getComponents, hashCode, toString
consistentWithEquals, decode, encode, getEncodedElementByteSize, structuralValue, verifyDeterministic, verifyDeterministic
public static <T> SetCoder<T> of(Coder<T> elementCoder)
SetCoder
with the given elementCoder
.public void verifyDeterministic() throws Coder.NonDeterministicException
Coder.NonDeterministicException
if the coding is not deterministic.
In order for a Coder
to be considered deterministic, the following must be true:
Object.equals()
or Comparable.compareTo()
, if supported) have the same encoding.
Coder
always produces a canonical encoding, which is the same for an instance
of an object even if produced on different computers at different times.
verifyDeterministic
in class IterableLikeCoder<T,java.util.Set<T>>
NonDeterministicException
- always. Sets are not ordered, but they are encoded in the
order of an arbitrary iteration.Coder.NonDeterministicException
- if this coder is not deterministic.public TypeDescriptor<java.util.Set<T>> getEncodedTypeDescriptor()
Coder
TypeDescriptor
for the type encoded.getEncodedTypeDescriptor
in class Coder<java.util.Set<T>>
protected final java.util.Set<T> decodeToIterable(java.util.List<T> decodedElements)
IterableT
, this coder's associated Iterable
-like subtype,
from a list of decoded elements.decodeToIterable
in class IterableLikeCoder<T,java.util.Set<T>>
Set
built from the elements in the List
decoded by IterableLikeCoder
.