Class IndexedListSerializer

All Implemented Interfaces:
JsonFormatVisitable

public final class IndexedListSerializer extends AsArraySerializerBase<Object>
This is an optimized serializer for Lists that can be efficiently traversed by index (as opposed to others, such as LinkedList that cannot}.
  • Constructor Details

  • Method Details

    • _withValueTypeSerializer

      protected StdContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts)
      Description copied from class: StdContainerSerializer
      Method that needs to be implemented to allow construction of a new serializer object with given TypeSerializer, used when addition type information is to be embedded.
      Specified by:
      _withValueTypeSerializer in class StdContainerSerializer<Object>
    • withResolved

      public IndexedListSerializer withResolved(BeanProperty property, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle, Object suppressableValue, boolean suppressNulls)
      Description copied from class: AsArraySerializerBase
      Factory method to use for creating differently configured instances, called by this class (from #createContextual), overridden by implementation class.

      NOTE: only implemented for backwards-compatibility with 3.0 version JacksonModules, otherwise would be abstract: sub-classes really need to override.

      Overrides:
      withResolved in class AsArraySerializerBase<Object>
    • 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.

      Specified by:
      isEmpty in class StdContainerSerializer<Object>
    • hasSingleElement

      public boolean hasSingleElement(Object value)
      Description copied from class: StdContainerSerializer
      Method called to determine if the given value (of type handled by this serializer) contains exactly one element.

      Note: although it might seem sensible to instead define something like "getElementCount()" method, this would not work well for containers that do not keep track of size (like linked lists may not).

      Note, too, that this method is only called by serializer itself; and specifically is not used for non-array/collection types like Map or Map.Entry instances.

      Specified by:
      hasSingleElement in class StdContainerSerializer<Object>
    • serialize

      public final void serialize(Object value0, tools.jackson.core.JsonGenerator g, SerializationContext ctxt) 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:
      value0 - 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.
      Throws:
      tools.jackson.core.JacksonException
    • serializeContents

      public void serializeContents(Object value0, tools.jackson.core.JsonGenerator g, SerializationContext ctxt) throws tools.jackson.core.JacksonException
      Specified by:
      serializeContents in class AsArraySerializerBase<Object>
      Throws:
      tools.jackson.core.JacksonException
    • serializeContentsImpl

      private void serializeContentsImpl(List<?> value, tools.jackson.core.JsonGenerator g, SerializationContext ctxt) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • serializeContentsUsingImpl

      private void serializeContentsUsingImpl(List<?> value, tools.jackson.core.JsonGenerator g, SerializationContext ctxt, ValueSerializer<Object> ser) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • serializeTypedContentsImpl

      private void serializeTypedContentsImpl(List<?> value, tools.jackson.core.JsonGenerator g, SerializationContext ctxt) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException