use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class MappingMethod method getImportTypes.
@Override
public Set<Type> getImportTypes() {
Set<Type> types = new HashSet<>();
for (Parameter param : parameters) {
types.addAll(param.getType().getImportTypes());
}
types.addAll(getReturnType().getImportTypes());
for (Type type : thrownTypes) {
types.addAll(type.getImportTypes());
}
return types;
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class PresenceCheckMethodResolver method findMatchingPresenceCheckMethod.
private static SelectedMethod<SourceMethod> findMatchingPresenceCheckMethod(Method method, SelectionParameters selectionParameters, MappingBuilderContext ctx) {
MethodSelectors selectors = new MethodSelectors(ctx.getTypeUtils(), ctx.getElementUtils(), ctx.getTypeFactory(), ctx.getMessager());
Type booleanType = ctx.getTypeFactory().getType(Boolean.class);
List<SelectedMethod<SourceMethod>> matchingMethods = selectors.getMatchingMethods(method, getAllAvailableMethods(method, ctx.getSourceModel()), Collections.emptyList(), booleanType, booleanType, SelectionCriteria.forPresenceCheckMethods(selectionParameters));
if (matchingMethods.isEmpty()) {
return null;
}
if (matchingMethods.size() > 1) {
ctx.getMessager().printMessage(method.getExecutable(), Message.GENERAL_AMBIGUOUS_PRESENCE_CHECK_METHOD, selectionParameters.getSourceRHS().getSourceType().describe(), matchingMethods.stream().map(SelectedMethod::getMethod).map(Method::describe).collect(Collectors.joining(", ")));
return null;
}
return matchingMethods.get(0);
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class AdderWrapper method getThrownTypes.
@Override
public List<Type> getThrownTypes() {
List<Type> parentThrownTypes = super.getThrownTypes();
List<Type> result = new ArrayList<>(parentThrownTypes);
for (Type thrownTypeToExclude : thrownTypesToExclude) {
for (Type parentExceptionType : parentThrownTypes) {
if (parentExceptionType.isAssignableTo(thrownTypeToExclude)) {
result.remove(parentExceptionType);
}
}
}
return result;
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class AbstractMappingMethodBuilder method getName.
private String getName(Type type) {
StringBuilder builder = new StringBuilder();
for (Type typeParam : type.getTypeParameters()) {
builder.append(typeParam.getIdentification());
}
builder.append(type.getIdentification());
return builder.toString();
}
use of org.mapstruct.ap.internal.model.common.Type in project mapstruct by mapstruct.
the class MapperCreationProcessor method getExtraImports.
private SortedSet<Type> getExtraImports(TypeElement element, MapperOptions mapperOptions) {
SortedSet<Type> extraImports = new TreeSet<>();
for (TypeMirror extraImport : mapperOptions.imports()) {
Type type = typeFactory.getType(extraImport);
extraImports.add(type);
}
// Add original package if a dest package has been set
if (!"default".equals(mapperOptions.implementationPackage())) {
extraImports.add(typeFactory.getType(element));
}
return extraImports;
}
Aggregations