Search in sources :

Example 1 with Field

use of org.mapstruct.ap.internal.model.Field in project mapstruct by mapstruct.

the class AnnotationBasedComponentModelProcessor method buildAnnotatedConstructorForDecorator.

private AnnotatedConstructor buildAnnotatedConstructorForDecorator(Decorator decorator) {
    List<AnnotationMapperReference> mapperReferencesForConstructor = new ArrayList<AnnotationMapperReference>(decorator.getFields().size());
    for (Field field : decorator.getFields()) {
        if (field instanceof AnnotationMapperReference) {
            mapperReferencesForConstructor.add((AnnotationMapperReference) field);
        }
    }
    List<Annotation> mapperReferenceAnnotations = getMapperReferenceAnnotations();
    removeDuplicateAnnotations(mapperReferencesForConstructor, mapperReferenceAnnotations);
    return new AnnotatedConstructor(decorator.getName(), mapperReferencesForConstructor, mapperReferenceAnnotations, additionalPublicEmptyConstructor());
}
Also used : AnnotationMapperReference(org.mapstruct.ap.internal.model.AnnotationMapperReference) Field(org.mapstruct.ap.internal.model.Field) AnnotatedConstructor(org.mapstruct.ap.internal.model.AnnotatedConstructor) ArrayList(java.util.ArrayList) Annotation(org.mapstruct.ap.internal.model.Annotation)

Example 2 with Field

use of org.mapstruct.ap.internal.model.Field in project mapstruct by mapstruct.

the class AnnotationBasedComponentModelProcessor method adjustDecorator.

protected void adjustDecorator(Mapper mapper, InjectionStrategyPrism injectionStrategy) {
    Decorator decorator = mapper.getDecorator();
    for (Annotation typeAnnotation : getDecoratorAnnotations()) {
        decorator.addAnnotation(typeAnnotation);
    }
    decorator.removeConstructor();
    List<Annotation> annotations = getDelegatorReferenceAnnotations(mapper);
    List<Field> replacement = new ArrayList<Field>();
    if (!decorator.getMethods().isEmpty()) {
        for (Field field : decorator.getFields()) {
            replacement.add(replacementMapperReference(field, annotations, injectionStrategy));
        }
    }
    decorator.setFields(replacement);
}
Also used : Decorator(org.mapstruct.ap.internal.model.Decorator) Field(org.mapstruct.ap.internal.model.Field) ArrayList(java.util.ArrayList) Annotation(org.mapstruct.ap.internal.model.Annotation)

Aggregations

ArrayList (java.util.ArrayList)2 Annotation (org.mapstruct.ap.internal.model.Annotation)2 Field (org.mapstruct.ap.internal.model.Field)2 AnnotatedConstructor (org.mapstruct.ap.internal.model.AnnotatedConstructor)1 AnnotationMapperReference (org.mapstruct.ap.internal.model.AnnotationMapperReference)1 Decorator (org.mapstruct.ap.internal.model.Decorator)1