com.google.cloud.dataflow.sdk.coders

## Class SetCoder<T>

- java.lang.Object
- - com.google.cloud.dataflow.sdk.coders.StandardCoder<IterableT>
  - - com.google.cloud.dataflow.sdk.coders.IterableLikeCoder<T,Set<T>>
    - - com.google.cloud.dataflow.sdk.coders.SetCoder<T>

Type Parameters:
  `T` - the type of the elements of the set

All Implemented Interfaces:
  Coder<Set<T>>, Serializable

    public class SetCoder<T>
    extends IterableLikeCoder<T,Set<T>>

A `SetCoder` encodes any `Set` using the format of `IterableLikeCoder`. The elements may not be in a deterministic order, depending on the `Set` implementation.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder

`Coder.Context, Coder.NonDeterministicException`

### Constructor Summary

Constructors
`protected` `SetCoder(Coder<T> elemCoder)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`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.

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.IterableLikeCoder

`decode, encode, getCoderArguments, getElemCoder, getInstanceComponentsHelper, isRegisterByteSizeObserverCheap, registerByteSizeObserver`

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder

`asCloudObject, consistentWithEquals, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, getEncodingId, hashCode, structuralValue, toString, verifyDeterministic, verifyDeterministic`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### SetCoder

    protected SetCoder(Coder<T> elemCoder)

### Method Detail

#### of

    public static <T> SetCoder<T> of(Coder<T> elementCoder)

Produces a `SetCoder` with the given `elementCoder`.

#### of

    public static SetCoder<?> of(List<Object> components)

Dynamically typed constructor for JSON deserialization.

#### verifyDeterministic

    public void verifyDeterministic()
                             throws Coder.NonDeterministicException

Throw `Coder.NonDeterministicException` if the coding is not deterministic.

In order for a `Coder` to be considered deterministic, the following must be true:

- two values that compare as equal (via `Object.equals()` or `Comparable.compareTo()`, if supported) have the same encoding.
- the `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.

Specified by:
  `verifyDeterministic` in interface `Coder<Set<T>>`
Overrides:
  `verifyDeterministic` in class `IterableLikeCoder<T,Set<T>>`
Throws:
  `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.

#### getInstanceComponents

    public static <T> List<Object> getInstanceComponents(Set<T> exampleValue)

Returns the first element in this set if it is non-empty, otherwise returns `null`.

#### decodeToIterable

    protected final Set<T> decodeToIterable(List<T> decodedElements)

Builds an instance of `IterableT`, this coder's associated `Iterable`-like subtype, from a list of decoded elements.

Specified by:
  `decodeToIterable` in class `IterableLikeCoder<T,Set<T>>`
Returns:
  A new `Set` built from the elements in the `List` decoded by `IterableLikeCoder`.