use of org.mapstruct.ap.internal.model.Mapper in project mapstruct by mapstruct.
the class MapperCreationProcessor method getMapper.
private Mapper getMapper(TypeElement element, MapperConfiguration mapperConfig, List<SourceMethod> methods) {
List<MapperReference> mapperReferences = mappingContext.getMapperReferences();
List<MappingMethod> mappingMethods = getMappingMethods(mapperConfig, methods);
mappingMethods.addAll(mappingContext.getUsedVirtualMappings());
mappingMethods.addAll(mappingContext.getMappingsToGenerate());
Mapper mapper = new Mapper.Builder().element(element).mappingMethods(mappingMethods).mapperReferences(mapperReferences).options(options).versionInformation(versionInformation).decorator(getDecorator(element, methods, mapperConfig.implementationName(), mapperConfig.implementationPackage())).typeFactory(typeFactory).elementUtils(elementUtils).extraImports(getExtraImports(element)).implName(mapperConfig.implementationName()).implPackage(mapperConfig.implementationPackage()).build();
if (!mappingContext.getForgedMethodsUnderCreation().isEmpty()) {
messager.printMessage(element, Message.GENERAL_NOT_ALL_FORGED_CREATED, mappingContext.getForgedMethodsUnderCreation().keySet());
}
return mapper;
}
use of org.mapstruct.ap.internal.model.Mapper in project mapstruct by mapstruct.
the class MapperCreationProcessor method getMapper.
private Mapper getMapper(TypeElement element, MapperOptions mapperOptions, List<SourceMethod> methods) {
List<MappingMethod> mappingMethods = getMappingMethods(mapperOptions, methods);
mappingMethods.addAll(mappingContext.getUsedSupportedMappings());
mappingMethods.addAll(mappingContext.getMappingsToGenerate());
// handle fields
List<Field> fields = new ArrayList<>(mappingContext.getMapperReferences());
Set<Field> supportingFieldSet = new LinkedHashSet<>(mappingContext.getUsedSupportedFields());
addAllFieldsIn(mappingContext.getUsedSupportedMappings(), supportingFieldSet);
fields.addAll(supportingFieldSet);
// handle constructorfragments
Set<SupportingConstructorFragment> constructorFragments = new LinkedHashSet<>();
addAllFragmentsIn(mappingContext.getUsedSupportedMappings(), constructorFragments);
Mapper mapper = new Mapper.Builder().element(element).methods(mappingMethods).fields(fields).constructorFragments(constructorFragments).options(options).versionInformation(versionInformation).decorator(getDecorator(element, methods, mapperOptions)).typeFactory(typeFactory).elementUtils(elementUtils).extraImports(getExtraImports(element, mapperOptions)).implName(mapperOptions.implementationName()).implPackage(mapperOptions.implementationPackage()).suppressGeneratorTimestamp(mapperOptions.suppressTimestampInGenerated()).build();
if (!mappingContext.getForgedMethodsUnderCreation().isEmpty()) {
messager.printMessage(element, Message.GENERAL_NOT_ALL_FORGED_CREATED, mappingContext.getForgedMethodsUnderCreation().keySet());
}
if (element.getModifiers().contains(Modifier.PRIVATE)) {
// If the mapper element is private then we should report an error
// we can't generate an implementation for a private mapper
mappingContext.getMessager().printMessage(element, Message.GENERAL_CANNOT_IMPLEMENT_PRIVATE_MAPPER, element.getSimpleName().toString(), element.getKind() == ElementKind.INTERFACE ? "interface" : "class");
}
return mapper;
}
Aggregations