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
  • 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

      public String getModuleName()
      Specified by:
      getModuleName in class Module
    • version

      public com.fasterxml.jackson.core.Version version()
      Specified by:
      version in interface com.fasterxml.jackson.core.Versioned
      Specified by:
      version in class Module
    • setupModule

      public void setupModule(Module.SetupContext context)
      Specified by:
      setupModule in class Module
    • configureReadNullAsAbsent

      public PossibleModule configureReadNullAsAbsent(boolean value)
      Method to configure reading null values to Possible fields. If set to true, values will be deserialized to Possible.absent(), to be used as an escape hatch and accept null values into a Possible<T> field, avoiding a ValueInstantiationException. In this regard, you would set this method to true only 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 true can lead to semantic differences.

      If set to false, creates a Possible.of(Optional.empty)) instance when reading a null value, meaning only a Possible<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