T - the type of the elements of the setpublic class SetCoder<T> extends IterableLikeCoder<T,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 Set<T> |
decodeToIterable(List<T> decodedElements)
Builds an instance of
IterableT, this coder's associated Iterable-like
subtype, from a list of decoded elements. |
static <T> List<Object> |
getInstanceComponents(Set<T> exampleValue)
Returns the first element in this set if it is non-empty,
otherwise returns
null. |
static <T> SetCoder<T> |
of(Coder<T> elementCoder)
Produces a
SetCoder with the given elementCoder. |
static SetCoder<?> |
of(List<Object> components)
Dynamically typed constructor for JSON deserialization.
|
void |
verifyDeterministic()
Throw
Coder.NonDeterministicException if the coding is not deterministic. |
decode, encode, getCoderArguments, getElemCoder, getInstanceComponentsHelper, isRegisterByteSizeObserverCheap, registerByteSizeObserverasCloudObject, consistentWithEquals, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, getEncodingId, hashCode, structuralValue, toString, verifyDeterministic, verifyDeterministicpublic static <T> SetCoder<T> of(Coder<T> elementCoder)
SetCoder with the given elementCoder.public static SetCoder<?> of(List<Object> components)
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 interface Coder<Set<T>>verifyDeterministic in class IterableLikeCoder<T,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 static <T> List<Object> getInstanceComponents(Set<T> exampleValue)
null.protected final Set<T> decodeToIterable(List<T> decodedElements)
IterableT, this coder's associated Iterable-like
subtype, from a list of decoded elements.decodeToIterable in class IterableLikeCoder<T,Set<T>>Set built from the elements in the List decoded by
IterableLikeCoder.