use of org.mapstruct.ap.internal.model.MapperReference in project mapstruct by mapstruct.
the class AnnotationBasedComponentModelProcessor method buildAnnotatedConstructorForMapper.
private AnnotatedConstructor buildAnnotatedConstructorForMapper(Mapper mapper) {
List<MapperReference> mapperReferences = toMapperReferences(mapper.getFields());
List<AnnotationMapperReference> mapperReferencesForConstructor = new ArrayList<>(mapperReferences.size());
for (MapperReference mapperReference : mapperReferences) {
if (mapperReference.isUsed()) {
mapperReferencesForConstructor.add((AnnotationMapperReference) mapperReference);
}
}
List<Annotation> mapperReferenceAnnotations = getMapperReferenceAnnotations();
removeDuplicateAnnotations(mapperReferencesForConstructor, mapperReferenceAnnotations);
return AnnotatedConstructor.forComponentModels(mapper.getName(), mapperReferencesForConstructor, mapperReferenceAnnotations, mapper.getConstructor(), additionalPublicEmptyConstructor());
}
use of org.mapstruct.ap.internal.model.MapperReference 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.MapperReference in project mapstruct by mapstruct.
the class MappingResolverImpl method findMapperReference.
private MapperReference findMapperReference(Method method) {
for (MapperReference ref : mapperReferences) {
if (ref.getType().equals(method.getDeclaringMapper())) {
ref.setUsed(ref.isUsed() || !method.isStatic());
ref.setTypeRequiresImport(true);
return ref;
}
}
return null;
}
Aggregations