Class JDKStringLikeSerializer

All Implemented Interfaces:
JsonFormatVisitable

public class JDKStringLikeSerializer extends StdSerializer<Object>
"Combo" serializer used for JDK types that work almost like ToStringSerializer.
Since:
3.0
  • Field Details

  • Constructor Details

    • JDKStringLikeSerializer

      public JDKStringLikeSerializer(Class<?> handledType, int type)
  • Method Details

    • find

      public static final ValueSerializer<?> find(Class<?> raw)
    • isEmpty

      public boolean isEmpty(SerializationContext prov, Object value)
      Description copied from class: ValueSerializer
      Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).

      Default implementation will consider only null values to be empty.

      Overrides:
      isEmpty in class ValueSerializer<Object>
    • serialize

      public void serialize(Object value, tools.jackson.core.JsonGenerator g, SerializationContext provider) throws tools.jackson.core.JacksonException
      Description copied from class: ValueSerializer
      Method that can be called to ask implementation to serialize values of type this serializer handles.
      Specified by:
      serialize in class StdSerializer<Object>
      Parameters:
      value - Value to serialize; can not be null.
      g - Generator used to output resulting Json content
      provider - Context that can be used to get serializers for serializing Objects value contains, if any.
      Throws:
      tools.jackson.core.JacksonException
    • serializeWithType

      public void serializeWithType(Object value, tools.jackson.core.JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) throws tools.jackson.core.JacksonException
      Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix. This should work for most cases; some sub-classes may want to change this behavior.
      Overrides:
      serializeWithType in class ValueSerializer<Object>
      Parameters:
      value - Value to serialize; can not be null.
      g - Generator used to output resulting Json content
      ctxt - Context that can be used to get serializers for serializing Objects value contains, if any.
      typeSer - Type serializer to use for including type information
      Throws:
      tools.jackson.core.JacksonException
    • acceptJsonFormatVisitor

      public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
      Description copied from class: StdSerializer
      Default implementation specifies no format. This behavior is usually overriden by custom serializers.
      Specified by:
      acceptJsonFormatVisitor in interface JsonFormatVisitable
      Overrides:
      acceptJsonFormatVisitor in class StdSerializer<Object>
      typeHint - Type of element (entity like property) being visited