Package org.mapstruct.ap.internal.model
Class MappingBuilderContext
java.lang.Object
org.mapstruct.ap.internal.model.MappingBuilderContext
This class provides the context for the builders.
The context provides:
- Input for the building process, such as the source model (mapping methods found) and mapper references.
- Required factory, utility, reporting methods for building the mappings.
- Means to harbor results produced by the builders, such as forged- and supported mapping methods that should be generated in a later stage.
- Author:
- Sjaak Derksen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceResolves the most suitable way for mapping an element (property, iterable element etc.) from source to target. -
Constructor Summary
ConstructorsConstructorDescriptionMappingBuilderContext(TypeFactory typeFactory, ElementUtils elementUtils, TypeUtils typeUtils, FormattingMessager messager, VersionInformation versionInformation, AccessorNamingUtils accessorNaming, NullabilityResolver nullabilityResolver, EnumMappingStrategy enumMappingStrategy, Map<String, EnumTransformationStrategy> enumTransformationStrategies, Options options, MappingBuilderContext.MappingResolver mappingResolver, TypeElement mapper, List<SourceMethod> sourceModel, List<MapperReference> mapperReferences) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanGenerateAutoSubMappingBetween(Type sourceType, Type targetType) getExistingMappingMethod(MappingMethod newMappingMethod) Returns a map which is used to track which forged methods are under creation.getNullabilityInMapperScope(Element element) Resolves the JSpecify nullability of an element declared directly on the mapper (e.g. a mapping method's return type or one of its source parameters), using the mapper type's@NullMarkedscope as the enclosing scope for unannotated elements.booleanbooleanisJSpecifyNonNullReturn(Method method) Whether the return type of the given mapping method is JSpecify@NonNull(directly or via a@NullMarkedscope).
-
Constructor Details
-
MappingBuilderContext
public MappingBuilderContext(TypeFactory typeFactory, ElementUtils elementUtils, TypeUtils typeUtils, FormattingMessager messager, VersionInformation versionInformation, AccessorNamingUtils accessorNaming, NullabilityResolver nullabilityResolver, EnumMappingStrategy enumMappingStrategy, Map<String, EnumTransformationStrategy> enumTransformationStrategies, Options options, MappingBuilderContext.MappingResolver mappingResolver, TypeElement mapper, List<SourceMethod> sourceModel, List<MapperReference> mapperReferences)
-
-
Method Details
-
getForgedMethodsUnderCreation
Returns a map which is used to track which forged methods are under creation. Used for cutting the possible infinite recursion of forged method creation. Map is used instead of set because not all fields of ForgedMethods are used in equals/hashCode and we are interested only in the first created ForgedMethod- Returns:
- map of forged methods
-
getMapperTypeElement
-
getSourceModel
-
getMapperReferences
-
getTypeFactory
-
getElementUtils
-
getTypeUtils
-
getMessager
-
getVersionInformation
-
getAccessorNaming
-
getNullabilityResolver
-
getNullabilityInMapperScope
Resolves the JSpecify nullability of an element declared directly on the mapper (e.g. a mapping method's return type or one of its source parameters), using the mapper type's@NullMarkedscope as the enclosing scope for unannotated elements.- Parameters:
element- the element declared on the mapper to inspect- Returns:
- the resolved nullability (
NullabilityResolver.Nullability.UNKNOWNwhen JSpecify is disabled)
-
isJSpecifyNonNullReturn
Whether the return type of the given mapping method is JSpecify@NonNull(directly or via a@NullMarkedscope). When it is, a mapping method must not generatereturn null, so callers forceNullValueMappingStrategyGem.RETURN_DEFAULTsemantics.Update methods and
void-returning methods never generate areturn nulland are excluded.- Parameters:
method- the mapping method to inspect- Returns:
trueif the return type is@NonNull,falseotherwise
-
getEnumMappingStrategy
-
getEnumTransformationStrategies
-
getOptions
-
getMappingResolver
-
getMappingsToGenerate
-
getReservedNames
-
getExistingMappingMethod
-
getUsedSupportedMappings
-
getUsedSupportedFields
-
canGenerateAutoSubMappingBetween
- Parameters:
sourceType- from which an automatic sub-mapping needs to be generatedtargetType- to which an automatic sub-mapping needs to be generated- Returns:
trueif MapStruct is allowed to try and generate an automatic sub-mapping between the source and targetType
-
isErroneous
public boolean isErroneous()
-