Search in sources :

Example 1 with AnnotatedWithParams

use of com.fasterxml.jackson.databind.introspect.AnnotatedWithParams in project jackson-databind by FasterXML.

the class StringCollectionDeserializer method createContextual.

/*
    /**********************************************************
    /* Validation, post-processing
    /**********************************************************
     */
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    // May need to resolve types for delegate-based creators:
    JsonDeserializer<Object> delegate = null;
    if (_valueInstantiator != null) {
        AnnotatedWithParams delegateCreator = _valueInstantiator.getDelegateCreator();
        if (delegateCreator != null) {
            JavaType delegateType = _valueInstantiator.getDelegateType(ctxt.getConfig());
            delegate = findDeserializer(ctxt, delegateType, property);
        }
    }
    JsonDeserializer<?> valueDeser = _valueDeserializer;
    final JavaType valueType = _containerType.getContentType();
    if (valueDeser == null) {
        // [databind#125]: May have a content converter
        valueDeser = findConvertingContentDeserializer(ctxt, property, valueDeser);
        if (valueDeser == null) {
            // And we may also need to get deserializer for String
            valueDeser = ctxt.findContextualValueDeserializer(valueType, property);
        }
    } else {
        // if directly assigned, probably not yet contextual, so:
        valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, valueType);
    }
    // 11-Dec-2015, tatu: Should we pass basic `Collection.class`, or more refined? Mostly
    //   comes down to "List vs Collection" I suppose... for now, pass Collection
    Boolean unwrapSingle = findFormatFeature(ctxt, property, Collection.class, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    NullValueProvider nuller = findContentNullProvider(ctxt, property, valueDeser);
    if (isDefaultDeserializer(valueDeser)) {
        valueDeser = null;
    }
    return withResolved(delegate, valueDeser, nuller, unwrapSingle);
}
Also used : AnnotatedWithParams(com.fasterxml.jackson.databind.introspect.AnnotatedWithParams) NullValueProvider(com.fasterxml.jackson.databind.deser.NullValueProvider)

Example 2 with AnnotatedWithParams

use of com.fasterxml.jackson.databind.introspect.AnnotatedWithParams in project jackson-databind by FasterXML.

the class Java7SupportImpl method findConstructorName.

@Override
public PropertyName findConstructorName(AnnotatedParameter p) {
    AnnotatedWithParams ctor = p.getOwner();
    if (ctor != null) {
        ConstructorProperties props = ctor.getAnnotation(ConstructorProperties.class);
        if (props != null) {
            String[] names = props.value();
            int ix = p.getIndex();
            if (ix < names.length) {
                return PropertyName.construct(names[ix]);
            }
        }
    }
    return null;
}
Also used : AnnotatedWithParams(com.fasterxml.jackson.databind.introspect.AnnotatedWithParams) ConstructorProperties(java.beans.ConstructorProperties)

Aggregations

AnnotatedWithParams (com.fasterxml.jackson.databind.introspect.AnnotatedWithParams)2 NullValueProvider (com.fasterxml.jackson.databind.deser.NullValueProvider)1 ConstructorProperties (java.beans.ConstructorProperties)1