Class GsonJsonPayloadConverter
java.lang.Object
io.temporal.common.converter.GsonJsonPayloadConverter
- All Implemented Interfaces:
PayloadConverter
Implements conversion through GSON JSON processor. To extend use
GsonJsonPayloadConverter(Function) constructor.-
Constructor Summary
ConstructorsConstructorDescriptionGsonJsonPayloadConverter(Function<com.google.gson.GsonBuilder, com.google.gson.GsonBuilder> builderInterceptor) Constructs an instance giving an ability to overrideGsoninitialization. -
Method Summary
Modifier and TypeMethodDescription<T> TImplements conversion of a single value.EachPayloadConverterhas an Encoding Type that it handles.static PayloadConverterOptional<io.temporal.api.common.v1.Payload> Return empty if value is null.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.temporal.common.converter.PayloadConverter
withContext
-
Constructor Details
-
GsonJsonPayloadConverter
public GsonJsonPayloadConverter() -
GsonJsonPayloadConverter
public GsonJsonPayloadConverter(Function<com.google.gson.GsonBuilder, com.google.gson.GsonBuilder> builderInterceptor) Constructs an instance giving an ability to overrideGsoninitialization.- Parameters:
builderInterceptor- function that interceptsGsonBuilderconstruction.
-
-
Method Details
-
getInstance
-
getEncodingType
Description copied from interface:PayloadConverterEachPayloadConverterhas an Encoding Type that it handles. EachPayloadConvertershould add the information about its Encoding Type into thePayloadit produces insidePayloadConverter.toData(Object)by associating it with theEncodingKeys.METADATA_ENCODING_KEYkey attached to thePayload's Metadata usingPayload.Builder.putMetadata(String, ByteString).- Specified by:
getEncodingTypein interfacePayloadConverter- Returns:
- encoding type that this converter handles.
-
toData
public Optional<io.temporal.api.common.v1.Payload> toData(Object value) throws DataConverterException Return empty if value is null. Exception stack traces are converted to a single string stack trace to save space and make them more readable.- Specified by:
toDatain interfacePayloadConverter- Parameters:
value- Java value to convert.- Returns:
- converted value
- Throws:
DataConverterException- if conversion of the value passed as parameter failed for any reason.- See Also:
-
fromData
public <T> T fromData(io.temporal.api.common.v1.Payload content, Class<T> valueClass, Type valueType) throws DataConverterException Description copied from interface:PayloadConverterImplements conversion of a single value.- Specified by:
fromDatain interfacePayloadConverter- Parameters:
content- Serialized value to convert to a Java object.valueClass- type of the value stored in thecontentvalueType- generic type of the value stored in thecontent- Returns:
- converted Java object
- Throws:
DataConverterException- if conversion of the data passed as parameter failed for any reason.
-