/** * Helper method used to locate deserializers for properties the * type this deserializer handles contains (usually for properties of * bean types) * * @param type Type of property to deserialize * @param property Actual property object (field, method, constuctor parameter) used * for passing deserialized values; provided so deserializer can be contextualized if necessary */ protected JsonDeserializer<Object> findDeserializer(DeserializationContext ctxt, JavaType type, BeanProperty property) throws JsonMappingException { return ctxt.findContextualValueDeserializer(type, property); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { if ((_deser == null) && (_inputType != null) && (_creatorProps == null)) { return new FactoryBasedEnumDeserializer(this, ctxt.findContextualValueDeserializer(_inputType, property)); } return this; }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readPropertyValue(JsonParser p, BeanProperty prop, JavaType type) throws IOException { JsonDeserializer<Object> deser = findContextualValueDeserializer(type, prop); if (deser == null) { return reportBadDefinition(type, String.format( "Could not find JsonDeserializer for type %s (via property %s)", type, ClassUtil.nameOf(prop))); } return (T) deser.deserialize(p, this); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = findFormatFeature(ctxt, property, EnumSet.class, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); JsonDeserializer<?> deser = _enumDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_enumType, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, _enumType); } return withResolved(deser, unwrapSingle); }
protected final JsonDeserializer<Object> _findDefaultImplDeserializer(DeserializationContext ctxt) throws IOException { /* 06-Feb-2013, tatu: As per [databind#148], consider default implementation value of * {@link java.lang.Void} to mean "serialize as null"; as well as DeserializationFeature * to do swift mapping to null */ if (_defaultImpl == null) { if (!ctxt.isEnabled(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE)) { return NullifyingDeserializer.instance; } return null; } Class<?> raw = _defaultImpl.getRawClass(); if (ClassUtil.isBogusClass(raw)) { return NullifyingDeserializer.instance; } synchronized (_defaultImpl) { if (_defaultImplDeserializer == null) { _defaultImplDeserializer = ctxt.findContextualValueDeserializer( _defaultImpl, _property); } return _defaultImplDeserializer; } }
deser = ctxt.findContextualValueDeserializer(actual, _property); deser = ctxt.findContextualValueDeserializer(type, _property);
/** * Factory method used for building actual instances to be used with types * OTHER than POJOs. * resolves deserializers and checks for "null values". * * @since 2.9 */ public static PropertyBasedCreator construct(DeserializationContext ctxt, ValueInstantiator valueInstantiator, SettableBeanProperty[] srcCreatorProps, boolean caseInsensitive) throws JsonMappingException { final int len = srcCreatorProps.length; SettableBeanProperty[] creatorProps = new SettableBeanProperty[len]; for (int i = 0; i < len; ++i) { SettableBeanProperty prop = srcCreatorProps[i]; if (!prop.hasValueDeserializer()) { prop = prop.withValueDeserializer(ctxt.findContextualValueDeserializer(prop.getType(), prop)); } creatorProps[i] = prop; } return new PropertyBasedCreator(ctxt, valueInstantiator, creatorProps, caseInsensitive, false); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // First: if already got deserializer to delegate to, contextualize it: if (_delegateDeserializer != null) { JsonDeserializer<?> deser = ctxt.handleSecondaryContextualization(_delegateDeserializer, property, _delegateType); if (deser != _delegateDeserializer) { return withDelegate(_converter, _delegateType, deser); } return this; } // Otherwise: figure out what is the fully generic delegate type, then find deserializer JavaType delegateType = _converter.getInputType(ctxt.getTypeFactory()); return withDelegate(_converter, delegateType, ctxt.findContextualValueDeserializer(delegateType, property)); }
deser = ctxt.findContextualValueDeserializer(t, _property);
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _valueDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_fullType.getReferencedType(), property); } else { // otherwise directly assigned, probably not contextual yet: deser = ctxt.handleSecondaryContextualization(deser, property, _fullType.getReferencedType()); } TypeDeserializer typeDeser = _valueTypeDeserializer; if (typeDeser != null) { typeDeser = typeDeser.forProperty(property); } // !!! 23-Oct-2016, tatu: TODO: full support for configurable ValueInstantiators? if ((deser == _valueDeserializer) && (typeDeser == _valueTypeDeserializer)) { return this; } return withResolved(typeDeser, deser); }
/** * Factory method used for building actual instances to be used with POJOS: * resolves deserializers, checks for "null values". * * @since 2.9 */ public static PropertyBasedCreator construct(DeserializationContext ctxt, ValueInstantiator valueInstantiator, SettableBeanProperty[] srcCreatorProps, BeanPropertyMap allProperties) throws JsonMappingException { final int len = srcCreatorProps.length; SettableBeanProperty[] creatorProps = new SettableBeanProperty[len]; for (int i = 0; i < len; ++i) { SettableBeanProperty prop = srcCreatorProps[i]; if (!prop.hasValueDeserializer()) { prop = prop.withValueDeserializer(ctxt.findContextualValueDeserializer(prop.getType(), prop)); } creatorProps[i] = prop; } return new PropertyBasedCreator(ctxt, valueInstantiator, creatorProps, allProperties.isCaseInsensitive(), allProperties.hasAliases()); }
valueDeser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt);
final JavaType vt = _containerType.getContentType(); if (valueDeser == null) { valueDeser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt);
/** * Method called to finalize setup of this deserializer, * when it is known for which property deserializer is needed for. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // note: instead of finding key deserializer, with enums we actually // work with regular deserializers (less code duplication; but not // quite as clean as it ought to be) KeyDeserializer keyDeser = _keyDeserializer; if (keyDeser == null) { keyDeser = ctxt.findKeyDeserializer(_containerType.getKeyType(), property); } JsonDeserializer<?> valueDeser = _valueDeserializer; final JavaType vt = _containerType.getContentType(); if (valueDeser == null) { valueDeser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt); } TypeDeserializer vtd = _valueTypeDeserializer; if (vtd != null) { vtd = vtd.forProperty(property); } return withResolved(keyDeser, valueDeser, vtd, findContentNullProvider(ctxt, property, valueDeser)); }
JavaType type = ctxt.constructType(String.class); if (deser == null) { deser = ctxt.findContextualValueDeserializer(type, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, type);
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> valueDeser = _elementDeserializer; Boolean unwrapSingle = findFormatFeature(ctxt, property, _containerType.getRawClass(), JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); // May have a content converter valueDeser = findConvertingContentDeserializer(ctxt, property, valueDeser); final JavaType vt = _containerType.getContentType(); if (valueDeser == null) { valueDeser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt); } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } NullValueProvider nuller = findContentNullProvider(ctxt, property, valueDeser); return withResolved(elemTypeDeser, valueDeser, nuller, unwrapSingle); }
/** * Method called to finalize setup of this deserializer, * when it is known for which property deserializer is needed for. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { KeyDeserializer kd = _keyDeserializer; if (kd == null) { kd = ctxt.findKeyDeserializer(_containerType.containedType(0), property); } else { if (kd instanceof ContextualKeyDeserializer) { kd = ((ContextualKeyDeserializer) kd).createContextual(ctxt, property); } } JsonDeserializer<?> vd = _valueDeserializer; vd = findConvertingContentDeserializer(ctxt, property, vd); JavaType contentType = _containerType.containedType(1); if (vd == null) { vd = ctxt.findContextualValueDeserializer(contentType, property); } else { // if directly assigned, probably not yet contextual, so: vd = ctxt.handleSecondaryContextualization(vd, property, contentType); } TypeDeserializer vtd = _valueTypeDeserializer; if (vtd != null) { vtd = vtd.forProperty(property); } return withResolved(kd, vtd, vd); }
JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); if (existingDeserializer == null) { existingDeserializer = ctxt.findContextualValueDeserializer(delegateType, prop);
if (valueDeser == null) { valueDeser = ctxt.findContextualValueDeserializer(valueType, property);
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { if (_endpointDeserializer == null) { JavaType endpointType = _rangeType.containedType(0); if (endpointType == null) { // should this ever occur? endpointType = TypeFactory.unknownType(); } JsonDeserializer<Object> deser = ctxt.findContextualValueDeserializer(endpointType, property); return new RangeDeserializer(_rangeType, deser, _defaultBoundType); } return this; }