public class ObjectResolver extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Resolver.UnresolvedReference
UnresolvedReference is created to hold a logical pointer to a reference that
could not yet be loaded, as the @ref appears ahead of the referenced object's
definition.
|
Modifier and Type | Field and Description |
---|---|
protected JsonReader.MissingFieldHandler |
missingFieldHandler |
protected JsonReader |
reader |
protected Collection<Resolver.UnresolvedReference> |
unresolvedRefs |
Modifier | Constructor and Description |
---|---|
protected |
ObjectResolver(JsonReader reader) |
Modifier and Type | Method and Description |
---|---|
protected void |
assignField(Deque<JsonObject<String,Object>> stack,
JsonObject jsonObj,
Field field,
Object rhs)
Map Json Map object field to Java object field.
|
protected void |
cleanup() |
protected Object |
convertMapsToObjects(JsonObject<String,Object> root)
Walk a JsonObject (Map of String keys to values) and return the
Java object equivalent filled in as best as possible (everything
except unresolved reference fields or unresolved array/collection elements).
|
protected static void |
convertMapToKeysItems(JsonObject map)
Convert an input JsonObject map (known to represent a Map.class or derivative) that has regular keys and values
to have its keys placed into @keys, and its values placed into @items.
|
protected Object |
createJavaObjectInstance(Class clazz,
JsonObject jsonObj)
This method creates a Java Object instance based on the passed in parameters.
|
protected JsonReader.JsonClassReaderBase |
getCustomReader(Class c) |
static Class |
getRawType(Type t) |
protected JsonReader |
getReader() |
protected Map<Class,JsonReader.JsonClassReaderBase> |
getReaders() |
protected JsonObject |
getReferencedObj(Long ref) |
static Object |
newInstance(Class c,
JsonObject jsonObject) |
protected boolean |
notCustom(Class cls) |
protected void |
patchUnresolvedReferences()
For all fields where the value was "@ref":"n" where 'n' was the id of an object
that had not yet been encountered in the stream, make the final substitution.
|
protected Object |
readIfMatching(Object o,
Class compType,
Deque<JsonObject<String,Object>> stack) |
protected void |
rehashMaps()
Process Maps/Sets (fix up their internal indexing structure)
This is required because Maps hash items using hashCode(), which will
change between VMs.
|
protected void |
traverseArray(Deque<JsonObject<String,Object>> stack,
JsonObject<String,Object> jsonObj)
Traverse the JsonObject associated to an array (of any type).
|
protected void |
traverseCollection(Deque<JsonObject<String,Object>> stack,
JsonObject<String,Object> jsonObj)
Process java.util.Collection and it's derivatives.
|
void |
traverseFields(Deque<JsonObject<String,Object>> stack,
JsonObject<String,Object> jsonObj)
Walk the Java object fields and copy them from the JSON object to the Java object, performing
any necessary conversions on primitives, or deep traversals for field assignments to other objects,
arrays, Collections, or Maps.
|
protected void |
traverseMap(Deque<JsonObject<String,Object>> stack,
JsonObject<String,Object> jsonObj)
Process java.util.Map and it's derivatives.
|
protected JsonReader.MissingFieldHandler missingFieldHandler
protected final Collection<Resolver.UnresolvedReference> unresolvedRefs
protected final JsonReader reader
protected ObjectResolver(JsonReader reader)
public void traverseFields(Deque<JsonObject<String,Object>> stack, JsonObject<String,Object> jsonObj)
stack
- Stack (Deque) used for graph traversal.jsonObj
- a Map-of-Map representation of the current object being examined (containing all fields).protected void assignField(Deque<JsonObject<String,Object>> stack, JsonObject jsonObj, Field field, Object rhs)
stack
- Stack (Deque) used for graph traversal.jsonObj
- a Map-of-Map representation of the current object being examined (containing all fields).field
- a Java Field object representing where the jsonObj should be converted and stored.rhs
- the JSON value that will be converted and stored in the 'field' on the associated
Java target object.protected void traverseCollection(Deque<JsonObject<String,Object>> stack, JsonObject<String,Object> jsonObj)
jsonObj
- a Map-of-Map representation of the JSON input stream.protected void traverseArray(Deque<JsonObject<String,Object>> stack, JsonObject<String,Object> jsonObj)
stack
- a Stack (Deque) used to support graph traversal.jsonObj
- a Map-of-Map representation of the JSON input stream.protected Object readIfMatching(Object o, Class compType, Deque<JsonObject<String,Object>> stack)
protected JsonReader getReader()
protected Object convertMapsToObjects(JsonObject<String,Object> root)
root
- JsonObject reference to a Map-of-Maps representation of the JSON
input after it has been completely read.protected void cleanup()
protected void traverseMap(Deque<JsonObject<String,Object>> stack, JsonObject<String,Object> jsonObj)
stack
- a Stack (Deque) used to support graph traversal.jsonObj
- a Map-of-Map representation of the JSON input stream.protected static void convertMapToKeysItems(JsonObject map)
map
- Map to convertprotected Object createJavaObjectInstance(Class clazz, JsonObject jsonObj)
clazz
- Instance will be create of this class.jsonObj
- Map-of-Map representation of object to create.protected JsonObject getReferencedObj(Long ref)
protected JsonReader.JsonClassReaderBase getCustomReader(Class c)
protected void patchUnresolvedReferences()
protected void rehashMaps()
public static Object newInstance(Class c, JsonObject jsonObject)
protected Map<Class,JsonReader.JsonClassReaderBase> getReaders()
protected boolean notCustom(Class cls)
Copyright © 2016. All rights reserved.