Search in sources :

Example 1 with SimpleAnnotationDefinition

use of org.drools.modelcompiler.builder.generator.declaredtype.api.SimpleAnnotationDefinition in project drools by kiegroup.

the class DMNDeclaredField method getFieldAnnotations.

@Override
public List<AnnotationDefinition> getFieldAnnotations() {
    List<AnnotationDefinition> annotations = new ArrayList<>();
    if (codeGenConfig.isWithJacksonAnnotation()) {
        boolean isCollection = fieldDMNType.isCollection();
        DMNType narrowTypeHint = isCollection ? DMNTypeUtils.getRootBaseTypeOfCollection(fieldDMNType) : fieldDMNType;
        Optional<Class<?>> as = index.getJacksonDeserializeAs(narrowTypeHint);
        as.ifPresent(asClass -> annotations.add(new SimpleAnnotationDefinition("com.fasterxml.jackson.databind.annotation.JsonDeserialize").addValue(isCollection ? "contentAs" : "as", asClass.getCanonicalName() + ".class")));
    }
    if (codeGenConfig.isWithMPOpenApiAnnotation() || codeGenConfig.isWithIOSwaggerOASv3Annotation()) {
        annotateFieldWithOAS(annotations);
    }
    return annotations;
}
Also used : AnnotationDefinition(org.drools.modelcompiler.builder.generator.declaredtype.api.AnnotationDefinition) SimpleAnnotationDefinition(org.drools.modelcompiler.builder.generator.declaredtype.api.SimpleAnnotationDefinition) ArrayList(java.util.ArrayList) SimpleAnnotationDefinition(org.drools.modelcompiler.builder.generator.declaredtype.api.SimpleAnnotationDefinition) DMNType(org.kie.dmn.api.core.DMNType)

Aggregations

ArrayList (java.util.ArrayList)1 AnnotationDefinition (org.drools.modelcompiler.builder.generator.declaredtype.api.AnnotationDefinition)1 SimpleAnnotationDefinition (org.drools.modelcompiler.builder.generator.declaredtype.api.SimpleAnnotationDefinition)1 DMNType (org.kie.dmn.api.core.DMNType)1