Class MapSerializer<K,V>

Type Parameters:
K - Map key type to serialize
V - Map value type to serialize
All Implemented Interfaces:
javax.json.bind.serializer.JsonbSerializer<Map<K,V>>, RuntimeTypeInfo, CurrentItem<Map<K,V>>, EmbeddedItem

public class MapSerializer<K,V> extends AbstractContainerSerializer<Map<K,V>> implements EmbeddedItem
Serialize Map.
  • Constructor Details

  • Method Details

    • beforeSerialize

      protected void beforeSerialize(Map<K,V> obj)
      Check Map before serialization. Decide whether provided Map can be serialized as JsonObject or as JsonArray of map entries.
      Overrides:
      beforeSerialize in class AbstractContainerSerializer<Map<K,V>>
      Parameters:
      obj - Map to be serialized
    • serializeInternal

      protected void serializeInternal(Map<K,V> obj, javax.json.stream.JsonGenerator generator, javax.json.bind.serializer.SerializationContext ctx)
      Serialize content of provided Map. Passing execution to delegate instance.
      Specified by:
      serializeInternal in class AbstractContainerSerializer<Map<K,V>>
      Parameters:
      obj - Map to be serialized
      generator - JSON format generator
      ctx - JSON serialization context
    • writeStart

      protected void writeStart(javax.json.stream.JsonGenerator generator)
      Write start of Map serialization. Passing execution to delegate instance.
      Specified by:
      writeStart in class AbstractContainerSerializer<Map<K,V>>
      Parameters:
      generator - JSON format generator
    • writeStart

      protected void writeStart(String key, javax.json.stream.JsonGenerator generator)
      Write start of Map serialization. Passing execution to delegate instance.
      Specified by:
      writeStart in class AbstractContainerSerializer<Map<K,V>>
      Parameters:
      key - JSON key name
      generator - JSON format generator
    • writeEnd

      protected void writeEnd(javax.json.stream.JsonGenerator generator)
      Write end of Map serialization. Passing execution to delegate instance.
      Overrides:
      writeEnd in class AbstractContainerSerializer<Map<K,V>>
      Parameters:
      generator - JSON format generator
    • isNullable

      protected boolean isNullable()
      Return an information whether to serialize null values too.
      Returns:
      null values shall be serialized too when true
    • serializeKey

      protected void serializeKey()
      Flag to serialize the key in the map.
    • serializeValue

      protected void serializeValue()
      Flag to serialize the value in the map.
    • getValueType

      protected Type getValueType(Type valueType)
      In a map the type can refer to the key or the value type depending which one is currently being processed. The field actualTypeArgument controls which one is being serialized at the moment.
      Overrides:
      getValueType in class AbstractContainerSerializer<Map<K,V>>
      Parameters:
      valueType - The value type which should be of type Map<K,V>
      Returns:
      The type for the key or the value