public static class JacksonSerializer.Builder extends Object
JacksonSerializer
.
The RevisionResolver
is defaulted to an AnnotationRevisionResolver
, the Converter
to a
ChainingConverter
, the ObjectMapper
defaults to a ObjectMapper.ObjectMapper()
result and
the ClassLoader
to the ClassLoader of this
class.
Upon instantiation, the ObjectMapper will get two modules registered to it by default, (1) the
MetaDataDeserializer
and the (2) JavaTimeModule
. Lastly, if the provided converter is of type
ChainingConverter, the JacksonSerializer.registerConverters(org.axonframework.serialization.ChainingConverter)
is performed to automatically add the
JsonNodeToByteArrayConverter
and ByteArrayToJsonNodeConverter
.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
JacksonSerializer |
build()
Initializes a
JacksonSerializer as specified through this Builder. |
JacksonSerializer.Builder |
classLoader(ClassLoader classLoader)
Deprecated.
Ensure the ObjectMapper is configured with the correct class loader instead
|
JacksonSerializer.Builder |
converter(Converter converter)
Sets the
Converter used as a converter factory providing converter instances utilized by upcasters
to convert between different content types. |
JacksonSerializer.Builder |
lenientDeserialization()
Configures the underlying ObjectMapper to be lenient when deserializing JSON into Java objects.
|
JacksonSerializer.Builder |
objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets the
ObjectMapper used to serialize and parse the objects to JSON. |
JacksonSerializer.Builder |
revisionResolver(RevisionResolver revisionResolver)
Sets the
RevisionResolver used to resolve the revision from an object to be serialized. |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
public JacksonSerializer.Builder revisionResolver(RevisionResolver revisionResolver)
RevisionResolver
used to resolve the revision from an object to be serialized. Defaults to
an AnnotationRevisionResolver
which resolves the revision based on the contents of the
Revision
annotation on the serialized classes.revisionResolver
- a RevisionResolver
used to resolve the revision from an object to be
serializedpublic JacksonSerializer.Builder converter(Converter converter)
Converter
used as a converter factory providing converter instances utilized by upcasters
to convert between different content types. Defaults to a ChainingConverter
.converter
- a Converter
used as a converter factory providing converter instances utilized by
upcasters to convert between different content typespublic JacksonSerializer.Builder objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
ObjectMapper
used to serialize and parse the objects to JSON. This ObjectMapper allows for
customization of the serialized form. Defaults to the output of ObjectMapper.ObjectMapper()
.objectMapper
- an ObjectMapper
used to serialize and parse the objects to JSON@Deprecated public JacksonSerializer.Builder classLoader(ClassLoader classLoader)
Instead, ensure the ObjectMapper is configured with the correct class loader.
classLoader
- the ClassLoader
used to load classes with when deserializingobjectMapper(ObjectMapper)
,
TypeFactory.withClassLoader(ClassLoader)
public JacksonSerializer.Builder lenientDeserialization()
DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY
and
DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS
, and disables
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
.public JacksonSerializer build()
JacksonSerializer
as specified through this Builder.JacksonSerializer
as specified through this Builderprotected void validate() throws AxonConfigurationException
AxonConfigurationException
- if one field is asserted to be incorrect according to the Builder's
specificationsCopyright © 2010–2020. All rights reserved.