Search in sources :

Example 1 with AnnotationCollector

use of com.fasterxml.jackson.databind.introspect.AnnotationCollector in project beam by apache.

the class PipelineOptionsFactory method createBeanProperty.

private static BeanProperty createBeanProperty(Method method) {
    AnnotationCollector ac = AnnotationCollector.emptyCollector();
    for (Annotation ann : method.getAnnotations()) {
        ac = ac.addOrOverride(ann);
    }
    AnnotatedMethod annotatedMethod = new AnnotatedMethod(new TypeResolutionContext.Basic(MAPPER.getTypeFactory(), TypeBindings.emptyBindings()), method, ac.asAnnotationMap(), null);
    BeanPropertyDefinition propDef = SimpleBeanPropertyDefinition.construct(MAPPER.getDeserializationConfig(), annotatedMethod);
    JavaType type = MAPPER.constructType(method.getGenericReturnType());
    try {
        return new MethodProperty(propDef, type, MAPPER.getDeserializationConfig().findTypeDeserializer(type), annotatedMethod.getAllAnnotations(), annotatedMethod);
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    }
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) AnnotationCollector(com.fasterxml.jackson.databind.introspect.AnnotationCollector) AnnotatedMethod(com.fasterxml.jackson.databind.introspect.AnnotatedMethod) TypeResolutionContext(com.fasterxml.jackson.databind.introspect.TypeResolutionContext) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) SimpleBeanPropertyDefinition(com.fasterxml.jackson.databind.util.SimpleBeanPropertyDefinition) MethodProperty(com.fasterxml.jackson.databind.deser.impl.MethodProperty) Annotation(java.lang.annotation.Annotation)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 MethodProperty (com.fasterxml.jackson.databind.deser.impl.MethodProperty)1 AnnotatedMethod (com.fasterxml.jackson.databind.introspect.AnnotatedMethod)1 AnnotationCollector (com.fasterxml.jackson.databind.introspect.AnnotationCollector)1 BeanPropertyDefinition (com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition)1 TypeResolutionContext (com.fasterxml.jackson.databind.introspect.TypeResolutionContext)1 SimpleBeanPropertyDefinition (com.fasterxml.jackson.databind.util.SimpleBeanPropertyDefinition)1 Annotation (java.lang.annotation.Annotation)1