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
public class PossibleModule extends Module
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module
Module.SetupContext
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_READ_NULL_AS_ABSENT
-
Constructor Summary
Constructors Constructor Description PossibleModule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PossibleModuleconfigureReadNullAsAbsent(boolean value)Method to configure readingnullvalues toPossiblefields.StringgetModuleName()voidsetupModule(Module.SetupContext context)com.fasterxml.jackson.core.Versionversion()-
Methods inherited from class com.fasterxml.jackson.databind.Module
getDependencies, getTypeId
-
-
-
-
Field Detail
-
DEFAULT_READ_NULL_AS_ABSENT
public static final boolean DEFAULT_READ_NULL_AS_ABSENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getModuleName
public String getModuleName()
- Specified by:
getModuleNamein classModule
-
version
public com.fasterxml.jackson.core.Version version()
-
setupModule
public void setupModule(Module.SetupContext context)
- Specified by:
setupModulein classModule
-
configureReadNullAsAbsent
public PossibleModule configureReadNullAsAbsent(boolean value)
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
-
-