Google Cloud Dataflow SDK for Java, version 1.9.1
Class CoderFactories
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.coders.CoderFactories
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static <T> CoderFactory
forCoder(Coder<T> coder)
Creates aCoderFactory
that always returns the given coder.static <T> CoderFactory
fromStaticMethods(Class<T> clazz)
Creates aCoderFactory
built from particular static methods of a class that implementsCoder
.
-
-
-
Method Detail
-
fromStaticMethods
public static <T> CoderFactory fromStaticMethods(Class<T> clazz)
Creates aCoderFactory
built from particular static methods of a class that implementsCoder
.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 aCoder<T>
from componentCoder
s. It must accept oneCoder
argument for each generic type parameter ofT
. IfT
takes no generic type parameters, then theof()
factory method should take no arguments.The
getInstanceComponents
method will be used to decompose a value during theCoder
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 classMyClass<X>
and an actual type parameterFoo
, theCoderFactoryFromStaticMethods
will accept anyCoder<Foo>
and produce aCoder<MyClass<Foo>>
.For example, the
CoderFactory
returned byfromStaticMethods(ListCoder.class)
will produce aCoder<List<X>>
for anyCoder Coder<X>
. -
-
forCoder
public static <T> CoderFactory forCoder(Coder<T> coder)
Creates aCoderFactory
that always returns the given coder.The
getInstanceComponents
method of thisCoderFactory
always returns an empty list.
-
-