use of org.mapstruct.ap.internal.model.source.MapperOptions in project mapstruct by mapstruct.
the class AnnotationBasedComponentModelProcessor method process.
@Override
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) {
this.typeFactory = context.getTypeFactory();
MapperOptions mapperAnnotation = MapperOptions.getInstanceOn(mapperTypeElement, context.getOptions());
String componentModel = mapperAnnotation.componentModel();
InjectionStrategyGem injectionStrategy = mapperAnnotation.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<Field> iterator = mapper.getFields().listIterator();
while (iterator.hasNext()) {
Field reference = iterator.next();
if (reference instanceof MapperReference) {
iterator.remove();
iterator.add(replacementMapperReference(reference, annotations, injectionStrategy));
}
}
if (injectionStrategy == InjectionStrategyGem.CONSTRUCTOR) {
buildConstructors(mapper);
}
return mapper;
}
use of org.mapstruct.ap.internal.model.source.MapperOptions in project mapstruct by mapstruct.
the class MapperCreationProcessor method process.
@Override
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, List<SourceMethod> sourceModel) {
this.elementUtils = context.getElementUtils();
this.typeUtils = context.getTypeUtils();
this.messager = new MapperAnnotatedFormattingMessenger(context.getMessager(), mapperTypeElement, context.getTypeUtils());
this.options = context.getOptions();
this.versionInformation = context.getVersionInformation();
this.typeFactory = context.getTypeFactory();
this.accessorNaming = context.getAccessorNaming();
MapperOptions mapperOptions = MapperOptions.getInstanceOn(mapperTypeElement, context.getOptions());
List<MapperReference> mapperReferences = initReferencedMappers(mapperTypeElement, mapperOptions);
MappingBuilderContext ctx = new MappingBuilderContext(typeFactory, elementUtils, typeUtils, messager, accessorNaming, context.getEnumMappingStrategy(), context.getEnumTransformationStrategies(), options, new MappingResolverImpl(messager, elementUtils, typeUtils, typeFactory, new ArrayList<>(sourceModel), mapperReferences, options.isVerbose()), mapperTypeElement, // Consider removing those methods directly into MappingBuilderContext.
Collections.unmodifiableList(sourceModel), mapperReferences);
this.mappingContext = ctx;
return getMapper(mapperTypeElement, mapperOptions, sourceModel);
}
use of org.mapstruct.ap.internal.model.source.MapperOptions in project mapstruct by mapstruct.
the class MethodRetrievalProcessor method process.
@Override
public List<SourceMethod> process(ProcessorContext context, TypeElement mapperTypeElement, Void sourceModel) {
this.messager = context.getMessager();
this.typeFactory = context.getTypeFactory();
this.accessorNaming = context.getAccessorNaming();
this.typeUtils = context.getTypeUtils();
this.elementUtils = context.getElementUtils();
this.enumTransformationStrategies = context.getEnumTransformationStrategies();
this.options = context.getOptions();
this.messager.note(0, Message.PROCESSING_NOTE, mapperTypeElement);
MapperOptions mapperOptions = MapperOptions.getInstanceOn(mapperTypeElement, context.getOptions());
if (mapperOptions.hasMapperConfig()) {
this.messager.note(0, Message.CONFIG_NOTE, mapperOptions.mapperConfigType().asElement().getSimpleName());
}
if (!mapperOptions.isValid()) {
throw new AnnotationProcessingException("Couldn't retrieve @Mapper annotation", mapperTypeElement, mapperOptions.getAnnotationMirror());
}
List<SourceMethod> prototypeMethods = retrievePrototypeMethods(mapperTypeElement, mapperOptions);
return retrieveMethods(mapperTypeElement, mapperTypeElement, mapperOptions, prototypeMethods);
}
Aggregations