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 ofObjectMapperto handle unknown properties without throwing errors.static final Function<ObjectMapper,ObjectMapper> A mapper ofObjectMapperwith 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 givenObjectMapperJacksonResources(Function<ObjectMapper, ObjectMapper> mapper) Deprecated.use one of the static factories and then callwithMapperFunction(Function) -
Method Summary
Modifier and TypeMethodDescriptionstatic JacksonResourcescreate()Create with a pre-configuredObjectMapperfor all Discord4J related operations.static JacksonResourcescreateFromObjectMapper(ObjectMapper objectMapper) Create based onObjectMapperapplying on it all changes required for Discord4J related operations.Get theObjectMapperconfigured by this provider.withMapperFunction(Function<ObjectMapper, ObjectMapper> transformer) Return a newJacksonResourcesbased on this currentObjectMapperbut applying the given function.
-
Field Details
-
INITIALIZER
A mapper ofObjectMapperwith all the required options for Discord4J operations. -
HANDLE_UNKNOWN_PROPERTIES
A mapper ofObjectMapperto handle unknown properties without throwing errors.
-
-
Constructor Details
-
JacksonResources
Deprecated.usecreate()Create a defaultObjectMapperthat 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 givenObjectMapperCreate 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-configuredObjectMapperfor all Discord4J related operations. -
createFromObjectMapper
Create based onObjectMapperapplying on it all changes required for Discord4J related operations. -
withMapperFunction
Return a newJacksonResourcesbased on this currentObjectMapperbut applying the given function.- Parameters:
transformer- a mapper to enrich the currentObjectMapper- Returns:
- a new instance with the
transformerapplied
-
getObjectMapper
Get theObjectMapperconfigured by this provider.- Returns:
- a Jackson ObjectMapper used to map POJOs to and from JSON format
-
create()