Class JsonNullableJackson3Module

java.lang.Object
tools.jackson.databind.JacksonModule
org.openapitools.jackson.nullable.JsonNullableJackson3Module
All Implemented Interfaces:
tools.jackson.core.Versioned

public class JsonNullableJackson3Module extends tools.jackson.databind.JacksonModule
  • Nested Class Summary

    Nested classes/interfaces inherited from class tools.jackson.databind.JacksonModule

    tools.jackson.databind.JacksonModule.SetupContext
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
     
    int
     
    mapBlankStringToNull(boolean state)
    Configures whether blank strings (for example "" or " ") deserialized into a JsonNullable are mapped to JsonNullable.of(null) instead of JsonNullable.undefined().
    void
    setupModule(tools.jackson.databind.JacksonModule.SetupContext context)
     
    tools.jackson.core.Version
     

    Methods inherited from class tools.jackson.databind.JacksonModule

    getDependencies, getRegistrationId

    Methods inherited from class java.lang.Object

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

    • JsonNullableJackson3Module

      public JsonNullableJackson3Module()
  • Method Details

    • mapBlankStringToNull

      public JsonNullableJackson3Module mapBlankStringToNull(boolean state)
      Configures whether blank strings (for example "" or " ") deserialized into a JsonNullable are mapped to JsonNullable.of(null) instead of JsonNullable.undefined().

      This matters for PATCH semantics: a blank string sent by a client expresses an explicit intent to clear the value, which undefined() silently swallows.

      String-like targets (String, CharSequence and its implementations such as StringBuilder, and Character) are exempt: for those, a blank string is a legitimate value in its own right and is never diverted to this option. A deserializer the application has registered itself for the property's type is also exempt: it is given the blank string and decides the outcome, and this option does not override whatever that deserializer returns. In other words, the option only takes effect where the blank-string guard still runs, i.e. for non-string-like targets still handled by a deserializer Jackson itself ships. A converter declared with @JsonDeserialize(contentConverter = ...) on a JsonNullable property resolves to Jackson's own StdConvertingDeserializer for the wrapped value, so a blank string still takes the shortcut above and the converter is not invoked for it; unchanged from earlier versions. A DelegatingDeserializer an application registers around a type's deserializer, directly or via a ValueDeserializerModifier, is classified by the innermost deserializer it ultimately wraps rather than by its own class. A deserializer that extends one of Jackson's own concrete deserializers (EnumDeserializer, BeanDeserializer, NumberDeserializers.NumberDeserializer, ...) keeps this shortcut, since it inherits Jackson's own blank-string handling; one that implements deserialization on Jackson's abstract bases (ValueDeserializer, StdDeserializer, StdScalarDeserializer, ...) receives the token instead; and a wrapper that does not extend DelegatingDeserializer (or does not override getDelegatee()) is classified by its own class rather than by what it wraps, so a wrapper should extend DelegatingDeserializer to be seen through.

      Default is false for backwards compatibility.

      Parameters:
      state - true to map blank strings to JsonNullable.of(null)
      Returns:
      this module, for chaining
    • setupModule

      public void setupModule(tools.jackson.databind.JacksonModule.SetupContext context)
      Specified by:
      setupModule in class tools.jackson.databind.JacksonModule
    • version

      public tools.jackson.core.Version version()
      Specified by:
      version in interface tools.jackson.core.Versioned
      Specified by:
      version in class tools.jackson.databind.JacksonModule
    • 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 tools.jackson.databind.JacksonModule