Package dev.drtheo.autojson.schema.util
Class AbstractMapSchema<K,V>
java.lang.Object
dev.drtheo.autojson.schema.util.AbstractMapSchema<K,V>
- Type Parameters:
K- the key type.V- the value type.
- All Implemented Interfaces:
ObjectSchema<Map<K,,V>> Schema<Map<K,V>>
- Direct Known Subclasses:
JavaMapSchema,String2ObjectMapSchema
The base map schema.
- Implementation Note:
- the key type should have a registered
StringSchema. Otherwise, you should write an adapter for it likeString2ObjectMapSchema.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <To> KdecodeKey(JsonAdapter<Object, To> adapter, String key) <To> voiddeserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx, Map<K, V> map, String key) protected <To> StringencodeKey(JsonAdapter<Object, To> adapter, K key) protected StringSchema<K>findKeySchema(SchemaHolder holder, Class<K> type) <To> voidserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Obj ctx, Map<K, V> map) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.drtheo.autojson.schema.base.ObjectSchema
serialize, typeMethods inherited from interface dev.drtheo.autojson.schema.base.Schema
asArray, asObject, asPrimitive, asWrapper
-
Constructor Details
-
AbstractMapSchema
-
-
Method Details
-
findKeySchema
-
serialize
public <To> void serialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Obj ctx, Map<K, V> map) - Specified by:
serializein interfaceObjectSchema<K>- Type Parameters:
To- the type the adapter serializes to.- Parameters:
adapter- the adapter used to serialize this object.ctx- the serialization context. Used to provide the key-value pairs.map- the object you're serializing.
-
instantiate
- Specified by:
instantiatein interfaceObjectSchema<K>- Returns:
- A new instance of the object this schema serializes.
-
deserialize
public <To> void deserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx, Map<K, V> map, String key) - Specified by:
deserializein interfaceObjectSchema<K>- Type Parameters:
To- the type the adapter serializes to.- Parameters:
adapter- the adapter used to deserialize this object.ctx- the deserialization context. Used to query the deserialization.map- the object you're deserializing the data into.key- the name of the field you're deserializing.
-
decodeKey
-
encodeKey
-