flexjson.factories
Class JsonNumberObjectFactory
java.lang.Object
flexjson.factories.JsonNumberObjectFactory
- All Implemented Interfaces:
- ObjectFactory
public class JsonNumberObjectFactory
- extends Object
- implements ObjectFactory
This class exists because it possible we don't have any type information to guide us
to what object we should instantiate when dealing with type-less collections. When
this happens its possible a JsonNumber can come through, and since we will default
to the underlying type found in the JSON stream in these situations we need to convert
the JsonNumber to something valid: Double or Long.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JsonNumberObjectFactory
public JsonNumberObjectFactory()
instantiate
public Object instantiate(ObjectBinder context,
Object value,
Type targetType,
Class targetClass)
- Description copied from interface:
ObjectFactory
- This method is called by the deserializer to construct and bind an object. At the end of this method
the object should be fully constructed.
ObjectBinder
can be used to bind values into
the object according to default rules. For simple implementations you won't need to use this, but
for more complex or generic objects reusing methods like ObjectBinder.bind(Object, java.lang.reflect.Type)
and ObjectBinder.bindIntoCollection(java.util.Collection, java.util.Collection, java.lang.reflect.Type)
.
- Specified by:
instantiate
in interface ObjectFactory
- Parameters:
context
- the object binding context to keep track of where we are in the object graph
and used for binding into objects.value
- This is the value from the json object at the current path.targetType
- This is the type pulled from the object introspector. Used for Collections and generic types.targetClass
- concrete class pulled from the configuration of the deserializer.
- Returns:
- the fully bound object. At the end of this method the object should be fully constructed.
Copyright © 2014. All Rights Reserved.