com.google.cloud.dataflow.sdk.coders

## 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>

A `Coder` that wraps a `Coder<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 for `T`.

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 instance `x` that `x.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, see `ProtoCoder`, `AvroCoder`, or `JAXBCoder`.

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
`protected` `StringDelegateCoder(Class<T> clazz)`

### Method Summary

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

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

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

### Constructor Detail

#### StringDelegateCoder

    protected StringDelegateCoder(Class<T> clazz)

### Method Detail

#### of

    public static <T> StringDelegateCoder<T> of(Class<T> clazz)

#### toString

    public String toString()

Overrides:
  `toString` in class `DelegateCoder<T,String>`

#### getEncodingId

    public String getEncodingId()

The encoding id is the fully qualified name of the encoded/decoded class.

Specified by:
  `getEncodingId` in interface `Coder<T>`
Overrides:
  `getEncodingId` in class `DelegateCoder<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.