Class 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 _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.
      protected com.google.common.collect.BoundType _defaultBoundType  
      private java.lang.String NAME  
    • Constructor Summary

      Constructors 
      Constructor Description
      GuavaModule()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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.
      boolean equals​(java.lang.Object o)  
      java.lang.String getModuleName()  
      int hashCode()  
      void setupModule​(com.fasterxml.jackson.databind.Module.SetupContext context)  
      com.fasterxml.jackson.core.Version 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 Detail

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

      • GuavaModule

        public GuavaModule()
    • Method Detail

      • getModuleName

        public java.lang.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 java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object