T - the type of the elements of the setpublic class SetCoder<T> extends IterableLikeCoder<T,Set<T>>
SetCoder<T> encodes any Set<T>
as an encoding of an iterable of its elements. 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 the coder's associated
Iterable 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()
Not all sets have a deterministic encoding.
|
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)
public static SetCoder<?> of(List<Object> components)
public void verifyDeterministic()
throws Coder.NonDeterministicException
For example, HashSet comparison does not depend on element order, so
two HashSet instances may be equal but produce different encodings.
verifyDeterministic in interface Coder<Set<T>>verifyDeterministic in class IterableLikeCoder<T,Set<T>>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)
IterableLikeCoderIterable from a list
of decoded elements. If IterableT is a supertype of List<T>, the
derived class implementation is permitted to return decodedElements
directly.decodeToIterable in class IterableLikeCoder<T,Set<T>>