T - The type of objects coded.public class StringDelegateCoder<T> extends DelegateCoder<T,String>
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.
DelegateCoder.CodingFunction<InputT,OutputT>Coder.Context, Coder.NonDeterministicException| Modifier | Constructor and Description |
|---|---|
protected |
StringDelegateCoder(Class<T> clazz) |
| 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() |
decode, encode, getAllowedEncodings, getCoder, of, structuralValue, verifyDeterministicasCloudObject, ofgetCoderArguments, getInstanceComponentsconsistentWithEquals, equals, getComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, registerByteSizeObserver, verifyDeterministic, verifyDeterministicpublic static <T> StringDelegateCoder<T> of(Class<T> clazz)
public String toString()
toString in class DelegateCoder<T,String>public String getEncodingId()
getEncodingId in interface Coder<T>getEncodingId in class DelegateCoder<T,String>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.