protected SettableBeanProperty(PropertyName propName, JavaType type, PropertyName wrapper, TypeDeserializer typeDeser, Annotations contextAnnotations, PropertyMetadata metadata) { super(metadata); // 09-Jan-2009, tatu: Intern()ing makes sense since Jackson parsed // field names are (usually) interned too, hence lookups will be faster. // 23-Oct-2009, tatu: should this be disabled wrt [JACKSON-180]? // Probably need not, given that namespace of field/method names // is not unbounded, unlike potential JSON names. if (propName == null) { _propName = PropertyName.NO_NAME; } else { _propName = propName.internSimpleName(); } _type = type; _wrapperName = wrapper; _contextAnnotations = contextAnnotations; _viewMatcher = null; // 30-Jan-2012, tatu: Important: contextualize TypeDeserializer now... if (typeDeser != null) { typeDeser = typeDeser.forProperty(this); } _valueTypeDeserializer = typeDeser; _valueDeserializer = MISSING_VALUE_DESERIALIZER; _nullProvider = MISSING_VALUE_DESERIALIZER; }
/** * Method for finding a deserializer for root-level value. */ @SuppressWarnings("unchecked") public final JsonDeserializer<Object> findRootValueDeserializer(JavaType type) throws JsonMappingException { JsonDeserializer<Object> deser = _cache.findValueDeserializer(this, _factory, type); if (deser == null) { // can this occur? return null; } deser = (JsonDeserializer<Object>) handleSecondaryContextualization(deser, null, type); TypeDeserializer typeDeser = _factory.findTypeDeserializer(_config, type); if (typeDeser != null) { // important: contextualize to indicate this is for root value typeDeser = typeDeser.forProperty(null); return new TypeWrappedDeserializer(typeDeser, deser); } return deser; }
@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); }
vtd = vtd.forProperty(property);
valueTypeDeser = valueTypeDeser.forProperty(property);
/** * 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)); }
@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); }
@SuppressWarnings("unchecked") private JsonDeserializer<Object> _findDelegateDeserializer(DeserializationContext ctxt, JavaType delegateType, AnnotatedWithParams delegateCreator) throws JsonMappingException { // Need to create a temporary property to allow contextual deserializers: BeanProperty.Std property = new BeanProperty.Std(TEMP_PROPERTY_NAME, delegateType, null, delegateCreator, PropertyMetadata.STD_OPTIONAL); TypeDeserializer td = delegateType.getTypeHandler(); if (td == null) { td = ctxt.getConfig().findTypeDeserializer(delegateType); } // 04-May-2018, tatu: [databind#2021] check if there's custom deserializer attached // to type (resolved from parameter) JsonDeserializer<Object> dd = delegateType.getValueHandler(); if (dd == null) { dd = findDeserializer(ctxt, delegateType, property); } else { dd = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(dd, property, delegateType); } if (td != null) { td = td.forProperty(property); return new TypeWrappedDeserializer(td, dd); } return dd; }
/** * 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); }
/** * Method called to finalize setup of this deserializer, * after deserializer itself has been registered. This * is needed to handle recursive and transitive dependencies. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _valueDeserializer; TypeDeserializer typeDeser = _typeDeserializerForValue; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_containerType.getContentType(), property); } if (typeDeser != null) { typeDeser = typeDeser.forProperty(property); } if (deser == _valueDeserializer && typeDeser == _typeDeserializerForValue) { return this; } return withResolved(typeDeser, deser); }
/** * Method called to finalize setup of this deserializer, * after deserializer itself has been registered. This * is needed to handle recursive and transitive dependencies. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { KeyDeserializer keyDeser = _keyDeserializer; JsonDeserializer<?> deser = _valueDeserializer; TypeDeserializer typeDeser = _typeDeserializerForValue; // Do we need any contextualization? if ((keyDeser != null) && (deser != null) && (typeDeser == null)) { // nope return this; } if (keyDeser == null) { keyDeser = ctxt.findKeyDeserializer(_mapType.getKeyType(), property); } if (deser == null) { deser = ctxt.findContextualValueDeserializer(_mapType.getContentType(), property); } if (typeDeser != null) { typeDeser = typeDeser.forProperty(property); } return withResolved(keyDeser, typeDeser, deser); }
/** * We need to use this method to properly handle possible contextual variants of key and value * deserializers, as well as type deserializers. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { KeyDeserializer kd = keyDeserializer; if (kd == null) { kd = ctxt.findKeyDeserializer(type.getKeyType(), property); } JsonDeserializer<?> valueDeser = elementDeserializer; final JavaType vt = type.getContentType(); if (valueDeser == null) { valueDeser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt); } // Type deserializer is slightly different; must be passed, but needs to become contextual: TypeDeserializer vtd = elementTypeDeserializer; if (vtd != null) { vtd = vtd.forProperty(property); } return _createContextual(type, kd, vtd, valueDeser, creatorMethod, findContentNullProvider(ctxt, property, valueDeser)); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _valueDeserializer; TypeDeserializer typeDeser = _valueTypeDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_referencedType, property); } if (typeDeser != null) { typeDeser = typeDeser.forProperty(property); } if (deser == _valueDeserializer && typeDeser == _valueTypeDeserializer) { return this; } return withResolved(typeDeser, deser); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _valueDeserializer; TypeDeserializer typeDeser = _valueTypeDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_referencedType, property); } if (typeDeser != null) { typeDeser = typeDeser.forProperty(property); } if (deser == _valueDeserializer && typeDeser == _valueTypeDeserializer) { return this; } return withResolved(typeDeser, deser); }
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_arrayType.getContentType(), property); } else { // if directly assigned, probably not yet contextual, so: if (deser instanceof ContextualDeserializer) { deser = ((ContextualDeserializer) deser).createContextual(ctxt, property); } } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withDeserializer(elemTypeDeser, deser); }
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_arrayType.getContentType(), property); } else { // if directly assigned, probably not yet contextual, so: if (deser instanceof ContextualDeserializer) { deser = ((ContextualDeserializer) deser).createContextual(ctxt, property); } } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withDeserializer(elemTypeDeser, deser); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; // #125: May have a content converter deser = findConvertingContentDeserializer(ctxt, property, deser); final JavaType vt = _arrayType.getContentType(); if (deser == null) { deser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, vt); } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withDeserializer(elemTypeDeser, deser); }
@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); } if ((deser == _valueDeserializer) && (typeDeser == _valueTypeDeserializer)) { return this; } return withResolved(typeDeser, deser); }
@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); }
private JsonDeserializer<Object> _findDelegateDeserializer(DeserializationContext ctxt, JavaType delegateType, AnnotatedWithParams delegateCreator) throws JsonMappingException { // Need to create a temporary property to allow contextual deserializers: BeanProperty.Std property = new BeanProperty.Std(TEMP_PROPERTY_NAME, delegateType, null, _classAnnotations, delegateCreator, PropertyMetadata.STD_OPTIONAL); TypeDeserializer td = delegateType.getTypeHandler(); if (td == null) { td = ctxt.getConfig().findTypeDeserializer(delegateType); } JsonDeserializer<Object> dd = findDeserializer(ctxt, delegateType, property); if (td != null) { td = td.forProperty(property); return new TypeWrappedDeserializer(td, dd); } return dd; }