Search in sources :

Example 1 with DefaultDeserializationContext

use of com.fasterxml.jackson.databind.deser.DefaultDeserializationContext 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

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