Class MappingBuilderContext

java.lang.Object
org.mapstruct.ap.internal.model.MappingBuilderContext

public class MappingBuilderContext extends Object
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
  • Constructor Details

  • Method Details

    • getForgedMethodsUnderCreation

      public Map<ForgedMethod,ForgedMethod> 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

      public TypeElement getMapperTypeElement()
    • getSourceModel

      public List<SourceMethod> getSourceModel()
    • getMapperReferences

      public List<MapperReference> getMapperReferences()
    • getTypeFactory

      public TypeFactory getTypeFactory()
    • getElementUtils

      public ElementUtils getElementUtils()
    • getTypeUtils

      public TypeUtils getTypeUtils()
    • getMessager

      public FormattingMessager getMessager()
    • getVersionInformation

      public VersionInformation getVersionInformation()
    • getAccessorNaming

      public AccessorNamingUtils getAccessorNaming()
    • getNullabilityResolver

      public NullabilityResolver getNullabilityResolver()
    • getNullabilityInMapperScope

      public NullabilityResolver.Nullability 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 @NullMarked scope as the enclosing scope for unannotated elements.
      Parameters:
      element - the element declared on the mapper to inspect
      Returns:
      the resolved nullability (NullabilityResolver.Nullability.UNKNOWN when JSpecify is disabled)
    • isJSpecifyNonNullReturn

      public boolean isJSpecifyNonNullReturn(Method method)
      Whether the return type of the given mapping method is JSpecify @NonNull (directly or via a @NullMarked scope). When it is, a mapping method must not generate return null, so callers force NullValueMappingStrategyGem.RETURN_DEFAULT semantics.

      Update methods and void-returning methods never generate a return null and are excluded.

      Parameters:
      method - the mapping method to inspect
      Returns:
      true if the return type is @NonNull, false otherwise
    • getEnumMappingStrategy

      public EnumMappingStrategy getEnumMappingStrategy()
    • getEnumTransformationStrategies

      public Map<String,EnumTransformationStrategy> getEnumTransformationStrategies()
    • getOptions

      public Options getOptions()
    • getMappingResolver

      public MappingBuilderContext.MappingResolver getMappingResolver()
    • getMappingsToGenerate

      public List<MappingMethod> getMappingsToGenerate()
    • getReservedNames

      public List<String> getReservedNames()
    • getExistingMappingMethod

      public MappingMethod getExistingMappingMethod(MappingMethod newMappingMethod)
    • getUsedSupportedMappings

      public Set<SupportingMappingMethod> getUsedSupportedMappings()
    • getUsedSupportedFields

      public Set<Field> getUsedSupportedFields()
    • canGenerateAutoSubMappingBetween

      public boolean canGenerateAutoSubMappingBetween(Type sourceType, Type targetType)
      Parameters:
      sourceType - from which an automatic sub-mapping needs to be generated
      targetType - to which an automatic sub-mapping needs to be generated
      Returns:
      true if MapStruct is allowed to try and generate an automatic sub-mapping between the source and target Type
    • isErroneous

      public boolean isErroneous()