Search in sources :

Example 1 with SubclassMappingOptions

use of org.mapstruct.ap.internal.model.source.SubclassMappingOptions in project mapstruct by mapstruct.

the class MethodRetrievalProcessor method getMethodRequiringImplementation.

private SourceMethod getMethodRequiringImplementation(ExecutableType methodType, ExecutableElement method, List<Parameter> parameters, boolean containsTargetTypeParameter, MapperOptions mapperOptions, 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 = retrieveContextProvidedMethods(contextParameters, mapperToImplement, mapperOptions);
    BeanMappingOptions beanMappingOptions = BeanMappingOptions.getInstanceOn(BeanMappingGem.instanceOn(method), mapperOptions, method, messager, typeUtils, typeFactory);
    RepeatableMappings repeatableMappings = new RepeatableMappings();
    Set<MappingOptions> mappingOptions = repeatableMappings.getMappings(method, beanMappingOptions);
    IterableMappingOptions iterableMappingOptions = IterableMappingOptions.fromGem(IterableMappingGem.instanceOn(method), mapperOptions, method, messager, typeUtils);
    MapMappingOptions mapMappingOptions = MapMappingOptions.fromGem(MapMappingGem.instanceOn(method), mapperOptions, method, messager, typeUtils);
    EnumMappingOptions enumMappingOptions = EnumMappingOptions.getInstanceOn(method, mapperOptions, enumTransformationStrategies, messager);
    // We want to get as much error reporting as possible.
    // If targetParameter is not null it means we have an update method
    SubclassValidator subclassValidator = new SubclassValidator(messager, typeUtils);
    Set<SubclassMappingOptions> subclassMappingOptions = getSubclassMappings(sourceParameters, targetParameter != null ? null : resultType, method, beanMappingOptions, subclassValidator);
    return new SourceMethod.Builder().setExecutable(method).setParameters(parameters).setReturnType(returnType).setExceptionTypes(exceptionTypes).setMapper(mapperOptions).setBeanMappingOptions(beanMappingOptions).setMappingOptions(mappingOptions).setIterableMappingOptions(iterableMappingOptions).setMapMappingOptions(mapMappingOptions).setValueMappingOptionss(getValueMappings(method)).setEnumMappingOptions(enumMappingOptions).setSubclassMappings(subclassMappingOptions).setSubclassValidator(subclassValidator).setTypeUtils(typeUtils).setTypeFactory(typeFactory).setPrototypeMethods(prototypeMethods).setContextProvidedMethods(contextProvidedMethods).setVerboseLogging(options.isVerbose()).build();
}
Also used : ParameterProvidedMethods(org.mapstruct.ap.internal.model.source.ParameterProvidedMethods) SubclassValidator(org.mapstruct.ap.internal.model.source.SubclassValidator) BeanMappingOptions(org.mapstruct.ap.internal.model.source.BeanMappingOptions) EnumMappingOptions(org.mapstruct.ap.internal.model.source.EnumMappingOptions) SubclassMappingOptions(org.mapstruct.ap.internal.model.source.SubclassMappingOptions) MappingOptions(org.mapstruct.ap.internal.model.source.MappingOptions) BeanMappingOptions(org.mapstruct.ap.internal.model.source.BeanMappingOptions) MapMappingOptions(org.mapstruct.ap.internal.model.source.MapMappingOptions) ValueMappingOptions(org.mapstruct.ap.internal.model.source.ValueMappingOptions) IterableMappingOptions(org.mapstruct.ap.internal.model.source.IterableMappingOptions) MapMappingOptions(org.mapstruct.ap.internal.model.source.MapMappingOptions) IterableMappingOptions(org.mapstruct.ap.internal.model.source.IterableMappingOptions) Type(org.mapstruct.ap.internal.model.common.Type) DeclaredType(javax.lang.model.type.DeclaredType) ExecutableType(javax.lang.model.type.ExecutableType) SubclassMappingOptions(org.mapstruct.ap.internal.model.source.SubclassMappingOptions) EnumMappingOptions(org.mapstruct.ap.internal.model.source.EnumMappingOptions) Parameter(org.mapstruct.ap.internal.model.common.Parameter) SourceMethod(org.mapstruct.ap.internal.model.source.SourceMethod)

Aggregations

DeclaredType (javax.lang.model.type.DeclaredType)1 ExecutableType (javax.lang.model.type.ExecutableType)1 Parameter (org.mapstruct.ap.internal.model.common.Parameter)1 Type (org.mapstruct.ap.internal.model.common.Type)1 BeanMappingOptions (org.mapstruct.ap.internal.model.source.BeanMappingOptions)1 EnumMappingOptions (org.mapstruct.ap.internal.model.source.EnumMappingOptions)1 IterableMappingOptions (org.mapstruct.ap.internal.model.source.IterableMappingOptions)1 MapMappingOptions (org.mapstruct.ap.internal.model.source.MapMappingOptions)1 MappingOptions (org.mapstruct.ap.internal.model.source.MappingOptions)1 ParameterProvidedMethods (org.mapstruct.ap.internal.model.source.ParameterProvidedMethods)1 SourceMethod (org.mapstruct.ap.internal.model.source.SourceMethod)1 SubclassMappingOptions (org.mapstruct.ap.internal.model.source.SubclassMappingOptions)1 SubclassValidator (org.mapstruct.ap.internal.model.source.SubclassValidator)1 ValueMappingOptions (org.mapstruct.ap.internal.model.source.ValueMappingOptions)1