com.google.cloud.dataflow.sdk.coders

## Class CoderFactories

- java.lang.Object
- - com.google.cloud.dataflow.sdk.coders.CoderFactories

    public final class CoderFactories
    extends Object

Static utility methods for creating and working with `Coder`s.

### Method Summary

All Methods Static Methods Concrete Methods
`static <T> CoderFactory` `forCoder(Coder<T> coder)` Creates a `CoderFactory` that always returns the given coder.
`static <T> CoderFactory` `fromStaticMethods(Class<T> clazz)` Creates a `CoderFactory` built from particular static methods of a class that implements `Coder`.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### fromStaticMethods

    public static <T> CoderFactory fromStaticMethods(Class<T> clazz)

Creates a `CoderFactory` built from particular static methods of a class that implements `Coder`.

The class must have the following static methods:

- `public static Coder<T> of(Coder<X> argCoder1, Coder<Y> argCoder2, ...)`
- `public static List<Object> getInstanceComponents(T exampleValue);`

The `of(...)` method will be used to construct a `Coder<T>` from component `Coder`s. It must accept one `Coder` argument for each generic type parameter of `T`. If `T` takes no generic type parameters, then the `of()` factory method should take no arguments.

The `getInstanceComponents` method will be used to decompose a value during the `Coder` inference process, to automatically choose coders for the components.

Note that the class `T` to be coded may be a not-yet-specialized generic class. For a generic class `MyClass<X>` and an actual type parameter `Foo`, the `CoderFactoryFromStaticMethods` will accept any `Coder<Foo>` and produce a `Coder<MyClass<Foo>>`.

For example, the `CoderFactory` returned by `fromStaticMethods(ListCoder.class)` will produce a `Coder<List<X>>` for any `Coder Coder<X>`.

#### forCoder

    public static <T> CoderFactory forCoder(Coder<T> coder)

Creates a `CoderFactory` that always returns the given coder.

The `getInstanceComponents` method of this `CoderFactory` always returns an empty list.