Search in sources :

Example 1 with MethodSelectors

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);
}
Also used : Type(org.mapstruct.ap.internal.model.common.Type) SelectedMethod(org.mapstruct.ap.internal.model.source.selector.SelectedMethod) SelectedMethod(org.mapstruct.ap.internal.model.source.selector.SelectedMethod) SourceMethod(org.mapstruct.ap.internal.model.source.SourceMethod) Method(org.mapstruct.ap.internal.model.source.Method) MethodSelectors(org.mapstruct.ap.internal.model.source.selector.MethodSelectors)

Example 2 with MethodSelectors

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);
}
Also used : SelectedMethod(org.mapstruct.ap.internal.model.source.selector.SelectedMethod) MethodSelectors(org.mapstruct.ap.internal.model.source.selector.MethodSelectors)

Example 3 with MethodSelectors

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);
}
Also used : SelectedMethod(org.mapstruct.ap.internal.model.source.selector.SelectedMethod) MethodSelectors(org.mapstruct.ap.internal.model.source.selector.MethodSelectors)

Aggregations

MethodSelectors (org.mapstruct.ap.internal.model.source.selector.MethodSelectors)3 SelectedMethod (org.mapstruct.ap.internal.model.source.selector.SelectedMethod)3 Type (org.mapstruct.ap.internal.model.common.Type)1 Method (org.mapstruct.ap.internal.model.source.Method)1 SourceMethod (org.mapstruct.ap.internal.model.source.SourceMethod)1