public static class Transformer.Builder
extends java.lang.Object
The builder can add custom TypeAdapter and TypeAdapterFactory to the Transformer
Modifier and Type | Method and Description |
---|---|
<T> Transformer.Builder |
addTypeAdapter(java.lang.reflect.Type type,
TypeAdapter<T> adapter)
Adds a custom TypeAdapter to the Transformer
|
Transformer.Builder |
addTypeAdapterFactory(TypeAdapterFactory adapterFactory)
Adds a custom TypeAdapterFactory to the Transformer
|
Transformer.Builder |
addTypeAlias(java.lang.reflect.Type target,
java.lang.reflect.Type alias)
Registers an alias for a type.
|
Transformer |
build()
Builds the Transformer object with all the custom TypeAdapter
and TypeAdapterFactory objects added to the Transformer.Builder
|
public <T> Transformer.Builder addTypeAdapter(java.lang.reflect.Type type, TypeAdapter<T> adapter)
T
- The concrete java representation of the data typetype
- The data type that this adapter can work withadapter
- The TypeAdapter to be added to the Transformerjava.lang.IllegalArgumentException
- on null argumentspublic Transformer.Builder addTypeAdapterFactory(TypeAdapterFactory adapterFactory)
adapterFactory
- The TypeAdapterFactory to be added to the Transformerjava.lang.IllegalArgumentException
- on null argumentspublic Transformer.Builder addTypeAlias(java.lang.reflect.Type target, java.lang.reflect.Type alias)
The call binds the target
type to be serialized/deserialized as another alias
type.
This can be useful for binding interface types to their implementations.
target
- the target typealias
- the alias typejava.lang.IllegalArgumentException
- on null argumentsjava.lang.IllegalArgumentException
- if the same type is supplied for both target
and alias
public Transformer build()