Search in sources :

Example 1 with TypeWrappedDeserializer

use of com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer in project jackson-databind by FasterXML.

the class DeserializationContext method findRootValueDeserializer.

/**
     * 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;
}
Also used : TypeDeserializer(com.fasterxml.jackson.databind.jsontype.TypeDeserializer) TypeWrappedDeserializer(com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer)

Example 2 with TypeWrappedDeserializer

use of com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer in project beam by apache.

the class PipelineOptionsFactory method computeDeserializerForMethod.

private static JsonDeserializer<Object> computeDeserializerForMethod(Method method) {
    try {
        BeanProperty prop = createBeanProperty(method);
        AnnotatedMember annotatedMethod = prop.getMember();
        DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.get();
        Object maybeDeserializerClass = context.getAnnotationIntrospector().findDeserializer(annotatedMethod);
        JsonDeserializer<Object> jsonDeserializer = context.deserializerInstance(annotatedMethod, maybeDeserializerClass);
        if (jsonDeserializer == null) {
            jsonDeserializer = context.findContextualValueDeserializer(prop.getType(), prop);
        }
        TypeDeserializer typeDeserializer = context.getFactory().findTypeDeserializer(context.getConfig(), prop.getType());
        if (typeDeserializer != null) {
            jsonDeserializer = new TypeWrappedDeserializer(typeDeserializer, jsonDeserializer);
        }
        return jsonDeserializer;
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultDeserializationContext(com.fasterxml.jackson.databind.deser.DefaultDeserializationContext) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) AnnotatedMember(com.fasterxml.jackson.databind.introspect.AnnotatedMember) TypeDeserializer(com.fasterxml.jackson.databind.jsontype.TypeDeserializer) TypeWrappedDeserializer(com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer) BeanProperty(com.fasterxml.jackson.databind.BeanProperty)

Aggregations

TypeWrappedDeserializer (com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer)2 TypeDeserializer (com.fasterxml.jackson.databind.jsontype.TypeDeserializer)2 BeanProperty (com.fasterxml.jackson.databind.BeanProperty)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 DefaultDeserializationContext (com.fasterxml.jackson.databind.deser.DefaultDeserializationContext)1 AnnotatedMember (com.fasterxml.jackson.databind.introspect.AnnotatedMember)1