Search in sources :

Example 16 with Parameter

use of org.mapstruct.ap.internal.model.common.Parameter in project mapstruct by mapstruct.

the class MethodRetrievalProcessor method getMethodRequiringImplementation.

private SourceMethod getMethodRequiringImplementation(ExecutableType methodType, ExecutableElement method, List<Parameter> parameters, boolean containsTargetTypeParameter, MapperConfiguration mapperConfig, List<SourceMethod> prototypeMethods, TypeElement mapperToImplement) {
    Type returnType = typeFactory.getReturnType(methodType);
    List<Type> exceptionTypes = typeFactory.getThrownTypes(methodType);
    List<Parameter> sourceParameters = Parameter.getSourceParameters(parameters);
    List<Parameter> contextParameters = Parameter.getContextParameters(parameters);
    Parameter targetParameter = extractTargetParameter(parameters);
    Type resultType = selectResultType(returnType, targetParameter);
    boolean isValid = checkParameterAndReturnType(method, sourceParameters, targetParameter, contextParameters, resultType, returnType, containsTargetTypeParameter);
    if (!isValid) {
        return null;
    }
    ParameterProvidedMethods contextProvidedMethods = retrieveLifecycleMethodsFromContext(contextParameters, mapperToImplement, mapperConfig);
    return new SourceMethod.Builder().setExecutable(method).setParameters(parameters).setReturnType(returnType).setExceptionTypes(exceptionTypes).setMappings(getMappings(method)).setIterableMapping(IterableMapping.fromPrism(IterableMappingPrism.getInstanceOn(method), method, messager, typeUtils)).setMapMapping(MapMapping.fromPrism(MapMappingPrism.getInstanceOn(method), method, messager, typeUtils)).setBeanMapping(BeanMapping.fromPrism(BeanMappingPrism.getInstanceOn(method), method, messager, typeUtils)).setValueMappings(getValueMappings(method)).setTypeUtils(typeUtils).setMessager(messager).setTypeFactory(typeFactory).setMapperConfiguration(mapperConfig).setPrototypeMethods(prototypeMethods).setContextProvidedMethods(contextProvidedMethods).build();
}
Also used : Type(org.mapstruct.ap.internal.model.common.Type) DeclaredType(javax.lang.model.type.DeclaredType) ExecutableType(javax.lang.model.type.ExecutableType) ParameterProvidedMethods(org.mapstruct.ap.internal.model.source.ParameterProvidedMethods) Parameter(org.mapstruct.ap.internal.model.common.Parameter)

Aggregations

Parameter (org.mapstruct.ap.internal.model.common.Parameter)16 ArrayList (java.util.ArrayList)8 Type (org.mapstruct.ap.internal.model.common.Type)8 DeclaredType (javax.lang.model.type.DeclaredType)4 ExecutableType (javax.lang.model.type.ExecutableType)4 HashSet (java.util.HashSet)3 SourceMethod (org.mapstruct.ap.internal.model.source.SourceMethod)3 ParameterBinding (org.mapstruct.ap.internal.model.common.ParameterBinding)2 ParameterProvidedMethods (org.mapstruct.ap.internal.model.source.ParameterProvidedMethods)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 ArrayType (javax.lang.model.type.ArrayType)1 PrimitiveType (javax.lang.model.type.PrimitiveType)1 TypeMirror (javax.lang.model.type.TypeMirror)1 TypeVariable (javax.lang.model.type.TypeVariable)1 WildcardType (javax.lang.model.type.WildcardType)1 PropertyEntry.forSourceReference (org.mapstruct.ap.internal.model.source.PropertyEntry.forSourceReference)1