Search in sources :

Example 1 with InjectionStrategyPrism

use of org.mapstruct.ap.internal.prism.InjectionStrategyPrism in project mapstruct by mapstruct.

the class AnnotationBasedComponentModelProcessor method process.

@Override
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) {
    this.typeFactory = context.getTypeFactory();
    MapperConfiguration mapperConfiguration = MapperConfiguration.getInstanceOn(mapperTypeElement);
    String componentModel = mapperConfiguration.componentModel(context.getOptions());
    InjectionStrategyPrism injectionStrategy = mapperConfiguration.getInjectionStrategy();
    if (!getComponentModelIdentifier().equalsIgnoreCase(componentModel)) {
        return mapper;
    }
    for (Annotation typeAnnotation : getTypeAnnotations(mapper)) {
        mapper.addAnnotation(typeAnnotation);
    }
    if (!requiresGenerationOfDecoratorClass()) {
        mapper.removeDecorator();
    } else if (mapper.getDecorator() != null) {
        adjustDecorator(mapper, injectionStrategy);
    }
    List<Annotation> annotations = getMapperReferenceAnnotations();
    ListIterator<MapperReference> iterator = mapper.getReferencedMappers().listIterator();
    while (iterator.hasNext()) {
        MapperReference reference = iterator.next();
        iterator.remove();
        iterator.add(replacementMapperReference(reference, annotations, injectionStrategy));
    }
    if (injectionStrategy == InjectionStrategyPrism.CONSTRUCTOR) {
        buildConstructors(mapper);
    }
    return mapper;
}
Also used : InjectionStrategyPrism(org.mapstruct.ap.internal.prism.InjectionStrategyPrism) MapperReference(org.mapstruct.ap.internal.model.MapperReference) AnnotationMapperReference(org.mapstruct.ap.internal.model.AnnotationMapperReference) MapperConfiguration(org.mapstruct.ap.internal.util.MapperConfiguration) Annotation(org.mapstruct.ap.internal.model.Annotation)

Aggregations

Annotation (org.mapstruct.ap.internal.model.Annotation)1 AnnotationMapperReference (org.mapstruct.ap.internal.model.AnnotationMapperReference)1 MapperReference (org.mapstruct.ap.internal.model.MapperReference)1 InjectionStrategyPrism (org.mapstruct.ap.internal.prism.InjectionStrategyPrism)1 MapperConfiguration (org.mapstruct.ap.internal.util.MapperConfiguration)1