Class JsonNullableModule

java.lang.Object
com.fasterxml.jackson.databind.Module
org.openapitools.jackson.nullable.JsonNullableModule
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned

public class JsonNullableModule 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
  • 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(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
  • Constructor Details

    • JsonNullableModule

      public JsonNullableModule()
  • Method Details

    • mapBlankStringToNull

      public JsonNullableModule 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 StdDelegatingDeserializer 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 BeanDeserializerModifier, 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 (JsonDeserializer, 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(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
    • 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