diff options
Diffstat (limited to 'src/main/java/com/fasterxml/jackson/databind/deser')
3 files changed, 36 insertions, 3 deletions
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/ValueInstantiator.java b/src/main/java/com/fasterxml/jackson/databind/deser/ValueInstantiator.java index a0db47e7f..628b4f225 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/ValueInstantiator.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/ValueInstantiator.java @@ -4,6 +4,7 @@ import java.io.IOException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer; import com.fasterxml.jackson.databind.introspect.AnnotatedParameter; import com.fasterxml.jackson.databind.introspect.AnnotatedWithParams; @@ -178,6 +179,13 @@ public abstract class ValueInstantiator getValueTypeDesc()); } + public Object createFromObjectWith(DeserializationContext ctxt, + SettableBeanProperty[] props, PropertyValueBuffer buffer) + throws IOException + { + return createFromObjectWith(ctxt, buffer.getParameters(props)); + } + /** * Method to called to create value instance from JSON Object using * an intermediate "delegate" value to pass to createor method diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyBasedCreator.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyBasedCreator.java index f1d35ec19..c9b89fa76 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyBasedCreator.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyBasedCreator.java @@ -133,7 +133,7 @@ public final class PropertyBasedCreator public Object build(DeserializationContext ctxt, PropertyValueBuffer buffer) throws IOException { Object bean = _valueInstantiator.createFromObjectWith(ctxt, - buffer.getParameters(_allProperties)); + _allProperties, buffer); // returning null isn't quite legal, but let's let caller deal with that if (bean != null) { // Object Id to handle? diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyValueBuffer.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyValueBuffer.java index a2b35a908..ea9673947 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyValueBuffer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyValueBuffer.java @@ -97,6 +97,32 @@ public class PropertyValueBuffer } } + public boolean hasParameter(SettableBeanProperty prop) + { + if (_paramsSeenBig == null) { + return ((_paramsSeen >> prop.getCreatorIndex()) & 1) == 1; + } else { + return _paramsSeenBig.get(prop.getCreatorIndex()); + } + } + + public Object getParameter(SettableBeanProperty prop) + throws JsonMappingException + { + Object value; + if (hasParameter(prop)) { + value = _creatorParameters[prop.getCreatorIndex()]; + } else { + value = _creatorParameters[prop.getCreatorIndex()] = _findMissing(prop); + } + if (value == null && _context.isEnabled(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES)) { + throw _context.mappingException( + "Null value for creator property '%s'; DeserializationFeature.FAIL_ON_NULL_FOR_CREATOR_PARAMETERS enabled", + prop.getName(), prop.getCreatorIndex()); + } + return value; + } + /** * Method called to do necessary post-processing such as injection of values * and verification of values for required properties, @@ -104,7 +130,7 @@ public class PropertyValueBuffer * returns <code>true</code> (to indicate all creator properties are found), or when * then whole JSON Object has been processed, */ - protected Object[] getParameters(SettableBeanProperty[] props) + public Object[] getParameters(SettableBeanProperty[] props) throws JsonMappingException { // quick check to see if anything else is needed @@ -261,4 +287,3 @@ public class PropertyValueBuffer _buffered = new PropertyValue.Map(_buffered, value, key); } } - |