Package discord4j.discordjson.possible
Class PossibleModule
java.lang.Object
com.fasterxml.jackson.databind.Module
discord4j.discordjson.possible.PossibleModule
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module
Module.SetupContext -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconfigureReadNullAsAbsent(boolean value) Method to configure readingnullvalues toPossiblefields.voidsetupModule(Module.SetupContext context) com.fasterxml.jackson.core.Versionversion()Methods inherited from class com.fasterxml.jackson.databind.Module
getDependencies, getTypeId
-
Field Details
-
DEFAULT_READ_NULL_AS_ABSENT
public static final boolean DEFAULT_READ_NULL_AS_ABSENT- See Also:
-
-
Constructor Details
-
PossibleModule
public PossibleModule()
-
-
Method Details
-
getModuleName
- Specified by:
getModuleNamein classModule
-
version
public com.fasterxml.jackson.core.Version version() -
setupModule
- Specified by:
setupModulein classModule
-
configureReadNullAsAbsent
Method to configure readingnullvalues toPossiblefields. If set totrue, values will be deserialized toPossible.absent(), to be used as an escape hatch and acceptnullvalues into aPossible<T>field, avoiding aValueInstantiationException. In this regard, you would set this method totrueonly if you encounter such exceptions due to incorrect field type or a transient issue with the JSON input.It is imperative to consider this can also interfere with methods that have distinct "null" vs "absent" behavior, and that writing a read value with this setting to
truecan lead to semantic differences.If set to
false, creates aPossible.of(Optional.empty))instance when reading anullvalue, meaning only aPossible<Optional<T>>field is the type to properly work with this setting.Defaults to
DEFAULT_READ_NULL_AS_ABSENT.- Parameters:
value- whether to enable or disable this feature- Returns:
- this module
-