public class OrgJsonValueDeserializer extends ValueDeserializerAdapter<JSONTokener,Object>
ValueDeserializerAdapter.ComplexDeserializer<T,InputType,InputNodeType>| Constructor and Description |
|---|
OrgJsonValueDeserializer(org.qi4j.api.structure.Application application,
org.qi4j.api.structure.Module module,
org.qi4j.api.service.ServiceReference<org.qi4j.api.value.ValueDeserializer> serviceRef) |
| Modifier and Type | Method and Description |
|---|---|
protected JSONTokener |
adaptInput(InputStream input)
This method is always called first, this is a chance to wrap the input type.
|
protected Object |
asSimpleValue(Object inputNode) |
protected <T> T |
getObjectFieldValue(Object inputNode,
String key,
org.qi4j.functional.Function<Object,T> valueDeserializer)
Return null if the field do not exists.
|
protected boolean |
isObjectValue(Object inputNode) |
protected boolean |
objectHasField(Object inputNode,
String key) |
protected <T> void |
putArrayNodeInCollection(Object inputNode,
org.qi4j.functional.Function<Object,T> deserializer,
Collection<T> collection) |
protected <K,V> void |
putArrayNodeInMap(Object inputNode,
org.qi4j.functional.Function<Object,K> keyDeserializer,
org.qi4j.functional.Function<Object,V> valueDeserializer,
Map<K,V> map) |
protected <V> void |
putObjectNodeInMap(Object inputNode,
org.qi4j.functional.Function<Object,V> valueDeserializer,
Map<String,V> map) |
protected <T> Collection<T> |
readArrayInCollection(JSONTokener input,
org.qi4j.functional.Function<JSONTokener,T> deserializer,
Collection<T> collection) |
protected <K,V> Map<K,V> |
readMapInMap(JSONTokener input,
org.qi4j.functional.Function<JSONTokener,K> keyDeserializer,
org.qi4j.functional.Function<JSONTokener,V> valueDeserializer,
Map<K,V> map)
A Map<K,V> is serialized in an array of entries objects.
|
protected JSONObject |
readObjectTree(JSONTokener input) |
protected Object |
readPlainValue(JSONTokener input) |
deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, onDeserializationEnd, onDeserializationStart, registerComplexDeserializer, registerDeserializerpublic OrgJsonValueDeserializer(@Structure
org.qi4j.api.structure.Application application,
@Structure
org.qi4j.api.structure.Module module,
@Service
org.qi4j.api.service.ServiceReference<org.qi4j.api.value.ValueDeserializer> serviceRef)
protected JSONTokener adaptInput(InputStream input) throws Exception
ValueDeserializerAdapteradaptInput in class ValueDeserializerAdapter<JSONTokener,Object>input - InputStream to adaptException - that will be wrapped in a ValueSerializationExceptionprotected Object readPlainValue(JSONTokener input) throws Exception
readPlainValue in class ValueDeserializerAdapter<JSONTokener,Object>input - InputException - that will be wrapped in a ValueSerializationExceptionprotected <T> Collection<T> readArrayInCollection(JSONTokener input, org.qi4j.functional.Function<JSONTokener,T> deserializer, Collection<T> collection) throws Exception
readArrayInCollection in class ValueDeserializerAdapter<JSONTokener,Object>T - Parameterized collection typeinput - Inputdeserializer - Deserialization functioncollection - CollectionException - that will be wrapped in a ValueSerializationExceptionprotected <K,V> Map<K,V> readMapInMap(JSONTokener input, org.qi4j.functional.Function<JSONTokener,K> keyDeserializer, org.qi4j.functional.Function<JSONTokener,V> valueDeserializer, Map<K,V> map) throws Exception
ValueDeserializerAdapterHere is an example in JSON:
[
{ "key": "foo", "value": "bar" },
{ "key": "cathedral", "value": "bazar" }
]
And an empty Map:
[]
This allow to use any type as keys and values while keeping the Map order at the cost of having non-predictible order of key/value inside an entry object.
readMapInMap in class ValueDeserializerAdapter<JSONTokener,Object>K - Parameterized map key typeV - Parameterized map value typeinput - InputkeyDeserializer - Map key deserialization functionvalueDeserializer - Map value deserialization functionmap - MapException - that will be wrapped in a ValueSerializationExceptionprotected JSONObject readObjectTree(JSONTokener input) throws Exception
readObjectTree in class ValueDeserializerAdapter<JSONTokener,Object>input - InputException - that will be wrapped in a ValueSerializationExceptionprotected Object asSimpleValue(Object inputNode) throws Exception
asSimpleValue in class ValueDeserializerAdapter<JSONTokener,Object>Exceptionprotected boolean isObjectValue(Object inputNode) throws Exception
isObjectValue in class ValueDeserializerAdapter<JSONTokener,Object>Exceptionprotected boolean objectHasField(Object inputNode, String key) throws Exception
objectHasField in class ValueDeserializerAdapter<JSONTokener,Object>Exceptionprotected <T> T getObjectFieldValue(Object inputNode, String key, org.qi4j.functional.Function<Object,T> valueDeserializer) throws Exception
ValueDeserializerAdaptergetObjectFieldValue in class ValueDeserializerAdapter<JSONTokener,Object>T - Parameterized object field value typeinputNode - Input Nodekey - Object keyvalueDeserializer - Deserialization functionException - that will be wrapped in a ValueSerializationExceptionprotected <T> void putArrayNodeInCollection(Object inputNode, org.qi4j.functional.Function<Object,T> deserializer, Collection<T> collection) throws Exception
putArrayNodeInCollection in class ValueDeserializerAdapter<JSONTokener,Object>Exceptionprotected <K,V> void putArrayNodeInMap(Object inputNode, org.qi4j.functional.Function<Object,K> keyDeserializer, org.qi4j.functional.Function<Object,V> valueDeserializer, Map<K,V> map) throws Exception
putArrayNodeInMap in class ValueDeserializerAdapter<JSONTokener,Object>Exceptionprotected <V> void putObjectNodeInMap(Object inputNode, org.qi4j.functional.Function<Object,V> valueDeserializer, Map<String,V> map) throws Exception
putObjectNodeInMap in class ValueDeserializerAdapter<JSONTokener,Object>Exception