Google Cloud Dataflow SDK for Java, version 1.9.1
Class StringDelegateCoder<T>
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.coders.StandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.AtomicCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.CustomCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.DelegateCoder<T,String>
-
- com.google.cloud.dataflow.sdk.coders.StringDelegateCoder<T>
-
- Type Parameters:
T
- The type of objects coded.
- All Implemented Interfaces:
- Coder<T>, Serializable
public class StringDelegateCoder<T> extends DelegateCoder<T,String>
ACoder
that wraps aCoder<String>
and encodes/decodes values via string representations.To decode, the input byte stream is decoded to a
String
, and this is passed to the single-argument constructor forT
.To encode, the input value is converted via
toString()
, and this string is encoded.In order for this to operate correctly for a class
Clazz
, it must be the case for any instancex
thatx.equals(new Clazz(x.toString()))
.This method of encoding is not designed for ease of evolution of
Clazz
; it should only be used in cases where the class is stable or the encoding is not important. If evolution of the class is important, seeProtoCoder
,AvroCoder
, orJAXBCoder
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.cloud.dataflow.sdk.coders.DelegateCoder
DelegateCoder.CodingFunction<InputT,OutputT>
-
Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
StringDelegateCoder(Class<T> clazz)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description String
getEncodingId()
The encoding id is the fully qualified name of the encoded/decoded class.static <T> StringDelegateCoder<T>
of(Class<T> clazz)
String
toString()
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.DelegateCoder
decode, encode, getAllowedEncodings, getCoder, of, structuralValue, verifyDeterministic
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.CustomCoder
asCloudObject, of
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.AtomicCoder
getCoderArguments, getInstanceComponents
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder
consistentWithEquals, equals, getComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, registerByteSizeObserver, verifyDeterministic, verifyDeterministic
-
-
-
-
Method Detail
-
of
public static <T> StringDelegateCoder<T> of(Class<T> clazz)
-
toString
public String toString()
- Overrides:
toString
in classDelegateCoder<T,String>
-
getEncodingId
public String getEncodingId()
The encoding id is the fully qualified name of the encoded/decoded class.- Specified by:
getEncodingId
in interfaceCoder<T>
- Overrides:
getEncodingId
in classDelegateCoder<T,String>
- Returns:
- a
String
composed from the underlying coder class name and its encoding id. Note that this omits any description of the coding functions. These should be modified with care.
-
-