Class Jdk8Module

java.lang.Object
com.fasterxml.jackson.databind.Module
com.fasterxml.jackson.datatype.jdk8.Jdk8Module
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned

public class Jdk8Module extends com.fasterxml.jackson.databind.Module
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module

    com.fasterxml.jackson.databind.Module.SetupContext
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    See configureReadAbsentAsNull(boolean) for details of this configuration setting.
    protected boolean
    Configuration setting that determines whether `Optional.empty()` is considered "same as null" for serialization purposes; that is, to be filtered same as nulls are.
    static final boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    configureAbsentsAsNulls(boolean state)
    Deprecated.
    Since 2.13, no replacement, will be removed from Jackson 3.0 (when optional types will be part of core databind)
    Method for configuring handling of "absent" Optional values; absent meaning case where no value is found to pass via Creator method (constructor, factory method).
    boolean
     
     
    int
     
    void
    setupModule(com.fasterxml.jackson.databind.Module.SetupContext context)
     
    com.fasterxml.jackson.core.Version
     

    Methods inherited from class com.fasterxml.jackson.databind.Module

    getDependencies, getTypeId

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_READ_ABSENT_AS_NULL

      public static final boolean DEFAULT_READ_ABSENT_AS_NULL
      See Also:
    • _cfgWriteAbsentAsNull

      protected boolean _cfgWriteAbsentAsNull
      Configuration setting that determines whether `Optional.empty()` is considered "same as null" for serialization purposes; that is, to be filtered same as nulls are. If enabled, absent values are treated like nulls; if disabled, they are not. In either case, absent values are always considered "empty".

      Default value is `false` for backwards compatibility (2.5 and prior only had this behavior).

      Note that this setting MUST be changed BEFORE registering the module: changes after registration will have no effect.

      Note that in most cases it makes more sense to just use `NON_ABSENT` inclusion criteria for filtering out absent optionals; this setting is mostly useful for legacy use cases that predate version 2.6.

    • _cfgReadAbsentAsNull

      protected boolean _cfgReadAbsentAsNull
      See configureReadAbsentAsNull(boolean) for details of this configuration setting.
      Since:
      2.14
  • Constructor Details

    • Jdk8Module

      public Jdk8Module()
  • Method Details

    • setupModule

      public void setupModule(com.fasterxml.jackson.databind.Module.SetupContext context)
      Specified by:
      setupModule in class com.fasterxml.jackson.databind.Module
    • version

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

      @Deprecated public Jdk8Module configureAbsentsAsNulls(boolean state)
      Deprecated.
      Since 2.13, no replacement, will be removed from Jackson 3.0 (when optional types will be part of core databind)
      Configuration method that may be used to change configuration setting _cfgHandleAbsentAsNull: enabling means that `Optional.empty()` values are handled like Java nulls (wrt filtering on serialization); disabling that they are only treated as "empty" values, but not like native Java nulls. Recommended setting for this value is `false`. For compatibility with older versions of other "optional" values (like Guava optionals), it can be set to 'true'. The default is `false` for backwards compatibility.

      Note that in most cases it makes more sense to just use `NON_ABSENT` inclusion criteria for filtering out absent optionals; this setting is mostly useful for legacy use cases that predate version 2.6.

      Returns:
      This module instance, useful for chaining calls
      Since:
      2.6
    • configureReadAbsentAsNull

      public Jdk8Module configureReadAbsentAsNull(boolean state)
      Method for configuring handling of "absent" Optional values; absent meaning case where no value is found to pass via Creator method (constructor, factory method). If enabled (set to true) it will be deserialized as null; if disabled it will be read as "empty" Optional (same as if encountering actual JSON null value).

      Default is false for backwards compatibility (retains behavior pre-2.14); for Jackson 3.0 default will likely be changed.

      Since:
      2.14
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getModuleName

      public String getModuleName()
      Specified by:
      getModuleName in class com.fasterxml.jackson.databind.Module