Class GuavaModule

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

public class GuavaModule extends com.fasterxml.jackson.databind.Module
Basic Jackson Module that adds support for Guava types.

Current configurability includes:

  • configureAbsentsAsNulls (default: false): Determines whether inclusion strategy of NON_NULL should additionally consider Optional.absent() values (as POJO properties) to be excluded; if true, they will be excluded, if false, they will be included. Note that the defaults for other "Optional" types are different; Guava setting is chosen solely for backwards compatibility.
  • 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
    Configuration setting that determines whether `Optional.absent()` is considered "same as null" for serialization purposes; that is, to be filtered same as nulls are.
    protected com.google.common.collect.BoundType
     
    private final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    configureAbsentsAsNulls(boolean state)
    Configuration method that may be used to change configuration setting _cfgHandleAbsentAsNull: enabling means that `Optional.absent()` 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.
    defaultBoundType(com.google.common.collect.BoundType boundType)
    Configuration method that may be used to change the BoundType to be used when deserializing Range objects.
    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

    • NAME

      private final String NAME
      See Also:
    • _cfgHandleAbsentAsNull

      protected boolean _cfgHandleAbsentAsNull
      Configuration setting that determines whether `Optional.absent()` 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 `true` 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.

    • _defaultBoundType

      protected com.google.common.collect.BoundType _defaultBoundType
  • Constructor Details

    • GuavaModule

      public GuavaModule()
  • Method Details

    • getModuleName

      public String getModuleName()
      Specified by:
      getModuleName 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
    • setupModule

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

      public GuavaModule configureAbsentsAsNulls(boolean state)
      Configuration method that may be used to change configuration setting _cfgHandleAbsentAsNull: enabling means that `Optional.absent()` 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 other "optional" values (like JDK 8 optionals); but the default is `true` for backwards compatibility.
      Returns:
      This module instance, useful for chaining calls
      Since:
      2.6
    • defaultBoundType

      public GuavaModule defaultBoundType(com.google.common.collect.BoundType boundType)
      Configuration method that may be used to change the BoundType to be used when deserializing Range objects. This configuration will is used when the object to be deserialized has no bound type attribute. The default BoundType is CLOSED.
      Parameters:
      boundType - BoundType
      Returns:
      This module instance, useful for chaining calls
      Since:
      2.7
    • hashCode

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

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