public final class JsonDataConverter extends java.lang.Object implements DataConverter
JsonDataConverter(Function)
constructor. Thrift structures are converted using TJSONProtocol
. When using thrift only one argument of a method is expected.Constructor and Description |
---|
JsonDataConverter(java.util.function.Function<com.google.gson.GsonBuilder,com.google.gson.GsonBuilder> builderInterceptor)
Constructs an instance giving an ability to override
Gson initialization. |
Modifier and Type | Method and Description |
---|---|
<T> T |
fromData(byte[] content,
java.lang.Class<T> valueClass,
java.lang.reflect.Type valueType)
Implements conversion of a single value.
|
java.lang.Object[] |
fromDataArray(byte[] content,
java.lang.reflect.Type... valueTypes)
Implements conversion of an array of values of different types.
|
static DataConverter |
getInstance() |
byte[] |
toData(java.lang.Object... values)
When values is empty or it contains a single value and it is null then return empty blob.
|
public JsonDataConverter(java.util.function.Function<com.google.gson.GsonBuilder,com.google.gson.GsonBuilder> builderInterceptor)
Gson
initialization.builderInterceptor
- function that intercepts GsonBuilder
construction.public static DataConverter getInstance()
public byte[] toData(java.lang.Object... values) throws DataConverterException
toData
in interface DataConverter
values
- Java value to convert to String.DataConverterException
- if conversion of the value passed as parameter failed for any
reason.public <T> T fromData(byte[] content, java.lang.Class<T> valueClass, java.lang.reflect.Type valueType) throws DataConverterException
DataConverter
fromData
in interface DataConverter
content
- Serialized value to convert to a Java object.DataConverterException
- if conversion of the data passed as parameter failed for any
reason.public java.lang.Object[] fromDataArray(byte[] content, java.lang.reflect.Type... valueTypes) throws DataConverterException
DataConverter
fromDataArray
in interface DataConverter
content
- serialized value to convert to Java objects.DataConverterException
- if conversion of the data passed as parameter failed for any
reason.