Package discord4j.common
Class JacksonResources
java.lang.Object
discord4j.common.JacksonResources
Provides a centralized Jackson 2.10
ObjectMapper
allowing customization and
reuse across the application.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Function<ObjectMapper,
ObjectMapper> A mapper ofObjectMapper
to handle unknown properties without throwing errors.static final Function<ObjectMapper,
ObjectMapper> A mapper ofObjectMapper
with all the required options for Discord4J operations. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.JacksonResources
(ObjectMapper objectMapper) Deprecated.usecreateFromObjectMapper(ObjectMapper)
instead, but consider all Discord4J-related transformations are applied on the givenObjectMapper
JacksonResources
(Function<ObjectMapper, ObjectMapper> mapper) Deprecated.use one of the static factories and then callwithMapperFunction(Function)
-
Method Summary
Modifier and TypeMethodDescriptionstatic JacksonResources
create()
Create with a pre-configuredObjectMapper
for all Discord4J related operations.static JacksonResources
createFromObjectMapper
(ObjectMapper objectMapper) Create based onObjectMapper
applying on it all changes required for Discord4J related operations.Get theObjectMapper
configured by this provider.withMapperFunction
(Function<ObjectMapper, ObjectMapper> transformer) Return a newJacksonResources
based on this currentObjectMapper
but applying the given function.
-
Field Details
-
INITIALIZER
A mapper ofObjectMapper
with all the required options for Discord4J operations. -
HANDLE_UNKNOWN_PROPERTIES
A mapper ofObjectMapper
to handle unknown properties without throwing errors.
-
-
Constructor Details
-
JacksonResources
Deprecated.usecreate()
Create a defaultObjectMapper
that allows any field visibility, registers modules to handle Discord4J specific mappings and ignores unknown properties. -
JacksonResources
Deprecated.use one of the static factories and then callwithMapperFunction(Function)
Create a customObjectMapper
, based on the defaults given byJacksonResources()
.- Parameters:
mapper
- a Function to customize the ObjectMapper to be created
-
JacksonResources
Deprecated.usecreateFromObjectMapper(ObjectMapper)
instead, but consider all Discord4J-related transformations are applied on the givenObjectMapper
Create with a pre-configuredObjectMapper
. Using this will replace the recommended default and can lead to unexpected behavior and errors.- Parameters:
objectMapper
- a pre-configured ObjectMapper to use
-
-
Method Details
-
create
Create with a pre-configuredObjectMapper
for all Discord4J related operations. -
createFromObjectMapper
Create based onObjectMapper
applying on it all changes required for Discord4J related operations. -
withMapperFunction
Return a newJacksonResources
based on this currentObjectMapper
but applying the given function.- Parameters:
transformer
- a mapper to enrich the currentObjectMapper
- Returns:
- a new instance with the
transformer
applied
-
getObjectMapper
Get theObjectMapper
configured by this provider.- Returns:
- a Jackson ObjectMapper used to map POJOs to and from JSON format
-
create()