use of org.mapstruct.ap.internal.util.MapperConfiguration 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;
}
use of org.mapstruct.ap.internal.util.MapperConfiguration 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 = context.getMessager();
this.options = context.getOptions();
this.versionInformation = context.getVersionInformation();
this.typeFactory = context.getTypeFactory();
MapperConfiguration mapperConfig = MapperConfiguration.getInstanceOn(mapperTypeElement);
List<MapperReference> mapperReferences = initReferencedMappers(mapperTypeElement, mapperConfig);
MappingBuilderContext ctx = new MappingBuilderContext(typeFactory, elementUtils, typeUtils, messager, options, new MappingResolverImpl(messager, elementUtils, typeUtils, typeFactory, new ArrayList<Method>(sourceModel), mapperReferences), mapperTypeElement, // Consider removing those methods directly into MappingBuilderContext.
Collections.unmodifiableList(sourceModel), mapperReferences);
this.mappingContext = ctx;
return getMapper(mapperTypeElement, mapperConfig, sourceModel);
}
use of org.mapstruct.ap.internal.util.MapperConfiguration in project mapstruct by mapstruct.
the class MapperCreationProcessor method getExtraImports.
private SortedSet<Type> getExtraImports(TypeElement element) {
SortedSet<Type> extraImports = new TreeSet<Type>();
MapperConfiguration mapperConfiguration = MapperConfiguration.getInstanceOn(element);
for (TypeMirror extraImport : mapperConfiguration.imports()) {
Type type = typeFactory.getType(extraImport);
extraImports.add(type);
}
// Add original package if a dest package has been set
if (!"default".equals(mapperConfiguration.implementationPackage())) {
extraImports.add(typeFactory.getType(element));
}
return extraImports;
}
use of org.mapstruct.ap.internal.util.MapperConfiguration 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.typeUtils = context.getTypeUtils();
this.elementUtils = context.getElementUtils();
MapperConfiguration mapperConfig = MapperConfiguration.getInstanceOn(mapperTypeElement);
if (!mapperConfig.isValid()) {
throw new AnnotationProcessingException("Couldn't retrieve @Mapper annotation", mapperTypeElement, mapperConfig.getAnnotationMirror());
}
List<SourceMethod> prototypeMethods = retrievePrototypeMethods(mapperTypeElement, mapperConfig);
return retrieveMethods(mapperTypeElement, mapperTypeElement, mapperConfig, prototypeMethods);
}
Aggregations