Class MapSerializer<K,V>
java.lang.Object
org.eclipse.yasson.internal.serializer.AbstractItem<T>
org.eclipse.yasson.internal.serializer.AbstractContainerSerializer<Map<K,V>>
org.eclipse.yasson.internal.serializer.MapSerializer<K,V>
- 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 Summary
ConstructorsModifierConstructorDescriptionprotectedMapSerializer(SerializerBuilder builder) Creates an instance ofMapserialization. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbeforeSerialize(Map<K, V> obj) CheckMapbefore serialization.protected TypegetValueType(Type valueType) In a map the type can refer to the key or the value type depending which one is currently being processed.protected booleanReturn an information whether to serializenullvalues too.protected voidserializeInternal(Map<K, V> obj, javax.json.stream.JsonGenerator generator, javax.json.bind.serializer.SerializationContext ctx) Serialize content of providedMap.protected voidFlag to serialize the key in the map.protected voidFlag to serialize the value in the map.protected voidwriteEnd(javax.json.stream.JsonGenerator generator) Write end ofMapserialization.protected voidwriteStart(String key, javax.json.stream.JsonGenerator generator) Write start ofMapserialization.protected voidwriteStart(javax.json.stream.JsonGenerator generator) Write start ofMapserialization.Methods inherited from class org.eclipse.yasson.internal.serializer.AbstractContainerSerializer
addValueSerializer, getValueSerializer, serialize, serializeItem, serializerCaptorMethods inherited from class org.eclipse.yasson.internal.serializer.AbstractItem
getClassModel, getRuntimeType, getWrapper
-
Constructor Details
-
MapSerializer
Creates an instance ofMapserialization.- Parameters:
builder- current instance ofSerializerBuilder
-
-
Method Details
-
beforeSerialize
CheckMapbefore serialization. Decide whether providedMapcan be serialized asJsonObjector asJsonArrayof map entries.- Overrides:
beforeSerializein classAbstractContainerSerializer<Map<K,V>> - Parameters:
obj-Mapto be serialized
-
serializeInternal
protected void serializeInternal(Map<K, V> obj, javax.json.stream.JsonGenerator generator, javax.json.bind.serializer.SerializationContext ctx) Serialize content of providedMap. Passing execution to delegate instance.- Specified by:
serializeInternalin classAbstractContainerSerializer<Map<K,V>> - Parameters:
obj-Mapto be serializedgenerator- JSON format generatorctx- JSON serialization context
-
writeStart
protected void writeStart(javax.json.stream.JsonGenerator generator) Write start ofMapserialization. Passing execution to delegate instance.- Specified by:
writeStartin classAbstractContainerSerializer<Map<K,V>> - Parameters:
generator- JSON format generator
-
writeStart
Write start ofMapserialization. Passing execution to delegate instance.- Specified by:
writeStartin classAbstractContainerSerializer<Map<K,V>> - Parameters:
key- JSON key namegenerator- JSON format generator
-
writeEnd
protected void writeEnd(javax.json.stream.JsonGenerator generator) Write end ofMapserialization. Passing execution to delegate instance.- Overrides:
writeEndin classAbstractContainerSerializer<Map<K,V>> - Parameters:
generator- JSON format generator
-
isNullable
protected boolean isNullable()Return an information whether to serializenullvalues too.- Returns:
nullvalues shall be serialized too whentrue
-
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
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:
getValueTypein classAbstractContainerSerializer<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
-