use of org.mapstruct.ap.internal.model.source.selector.MethodSelectors 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.source.selector.MethodSelectors in project mapstruct by mapstruct.
the class LifecycleCallbackFactory method collectLifecycleCallbackMethods.
private static List<LifecycleCallbackMethodReference> collectLifecycleCallbackMethods(Method method, SelectionParameters selectionParameters, List<SourceMethod> callbackMethods, MappingBuilderContext ctx, Set<String> existingVariableNames) {
MethodSelectors selectors = new MethodSelectors(ctx.getTypeUtils(), ctx.getElementUtils(), ctx.getTypeFactory());
List<SelectedMethod<SourceMethod>> matchingMethods = selectors.getMatchingMethods(method, callbackMethods, Collections.<Type>emptyList(), method.getResultType(), SelectionCriteria.forLifecycleMethods(selectionParameters));
return toLifecycleCallbackMethodRefs(method, matchingMethods, ctx, existingVariableNames);
}
use of org.mapstruct.ap.internal.model.source.selector.MethodSelectors in project mapstruct by mapstruct.
the class LifecycleMethodResolver method collectLifecycleCallbackMethods.
private static List<LifecycleCallbackMethodReference> collectLifecycleCallbackMethods(Method method, Type targetType, SelectionParameters selectionParameters, List<SourceMethod> callbackMethods, MappingBuilderContext ctx, Set<String> existingVariableNames) {
MethodSelectors selectors = new MethodSelectors(ctx.getTypeUtils(), ctx.getElementUtils(), ctx.getTypeFactory(), ctx.getMessager());
List<SelectedMethod<SourceMethod>> matchingMethods = selectors.getMatchingMethods(method, callbackMethods, Collections.emptyList(), targetType, method.getReturnType(), SelectionCriteria.forLifecycleMethods(selectionParameters));
return toLifecycleCallbackMethodRefs(method, matchingMethods, ctx, existingVariableNames);
}
Aggregations