CoderFactories (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

com.google.cloud.dataflow.sdk.coders

Class CoderFactories



  • public final class CoderFactories
    extends Object
    Static utility methods for creating and working with Coders.
    • 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 Coders. 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.


Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Dataflow