Class NoOpTypeSerializer

java.lang.Object
tools.jackson.databind.jsontype.TypeSerializer
tools.jackson.databind.jsontype.impl.NoOpTypeSerializer

public class NoOpTypeSerializer extends TypeSerializer
Special TypeSerializer implementation used to explicitly block type serialization. This is used when a property or class is annotated with @JsonTypeInfo(use = Id.NONE), indicating that type information should not be included even if the value type has a class-level type info annotation.

Unlike returning null (which means "no special type handling, use defaults"), this actively prevents type information from being written.

Since:
3.1
  • Method Details

    • instance

      public static NoOpTypeSerializer instance()
    • forProperty

      public TypeSerializer forProperty(SerializationContext ctxt, BeanProperty prop)
      Description copied from class: TypeSerializer
      Method called to create contextual version, to be used for values of given property. This may be the type itself (as is the case for bean properties), or values contained (for Collection or Map valued properties).

      NOTE: since 3.0 has received context object as first argument.

      Specified by:
      forProperty in class TypeSerializer
    • getTypeInclusion

      public JsonTypeInfo.As getTypeInclusion()
      Description copied from class: TypeSerializer
      Accessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.
      Specified by:
      getTypeInclusion in class TypeSerializer
    • getPropertyName

      public String getPropertyName()
      Description copied from class: TypeSerializer
      Name of property that contains type information, if property-based inclusion is used.
      Specified by:
      getPropertyName in class TypeSerializer
    • getTypeIdResolver

      public TypeIdResolver getTypeIdResolver()
      Description copied from class: TypeSerializer
      Accessor for object that handles conversions between types and matching type ids.
      Specified by:
      getTypeIdResolver in class TypeSerializer
    • writeTypePrefix

      public tools.jackson.core.type.WritableTypeId writeTypePrefix(tools.jackson.core.JsonGenerator g, SerializationContext ctxt, tools.jackson.core.type.WritableTypeId typeId) throws tools.jackson.core.JacksonException
      Description copied from class: TypeSerializer
      Method called to write initial part of type information for given value, along with possible wrapping to use: details are specified by `typeId` argument. Note that for structured types (Object, Array), this call will add necessary start token so it should NOT be explicitly written, unlike with non-type-id value writes.
      Specified by:
      writeTypePrefix in class TypeSerializer
      Parameters:
      g - Generator to use for outputting type id and possible wrapping
      typeId - Details of what type id is to be written, how.
      Throws:
      tools.jackson.core.JacksonException
    • writeTypeSuffix

      public tools.jackson.core.type.WritableTypeId writeTypeSuffix(tools.jackson.core.JsonGenerator g, SerializationContext ctxt, tools.jackson.core.type.WritableTypeId typeId) throws tools.jackson.core.JacksonException
      Description copied from class: TypeSerializer
      Method called to write the "closing" part of type information for given value, along with possible closing wrapping to use: details are specified by `typeId` argument, which should be one returned from an earlier matching call to writeTypePrefix(...).
      Specified by:
      writeTypeSuffix in class TypeSerializer
      Parameters:
      g - Generator to use for outputting type id and possible wrapping
      typeId - Details of what type id is to be written, how.
      Throws:
      tools.jackson.core.JacksonException