Class BeanMappingMethod.Builder

    • Field Detail

      • userDefinedReturnType

        private Type userDefinedReturnType
      • returnTypeBuilder

        private BuilderType returnTypeBuilder
      • unprocessedConstructorProperties

        private java.util.Map<java.lang.String,​Accessor> unprocessedConstructorProperties
      • unprocessedTargetProperties

        private java.util.Map<java.lang.String,​Accessor> unprocessedTargetProperties
      • unprocessedSourceProperties

        private java.util.Map<java.lang.String,​Accessor> unprocessedSourceProperties
      • missingIgnoredSourceProperties

        private java.util.Set<java.lang.String> missingIgnoredSourceProperties
      • targetProperties

        private java.util.Set<java.lang.String> targetProperties
      • propertyMappings

        private final java.util.List<PropertyMapping> propertyMappings
      • unprocessedSourceParameters

        private final java.util.Set<Parameter> unprocessedSourceParameters
      • existingVariableNames

        private final java.util.Set<java.lang.String> existingVariableNames
      • unprocessedDefinedTargets

        private final java.util.Map<java.lang.String,​java.util.Set<MappingReference>> unprocessedDefinedTargets
      • hasFactoryMethod

        private boolean hasFactoryMethod
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • doesNotAllowAbstractReturnTypeAndCanBeConstructed

        private boolean doesNotAllowAbstractReturnTypeAndCanBeConstructed​(Type returnTypeImpl)
      • allowsAbstractReturnTypeAndIsEitherAbstractOrCanBeConstructed

        private boolean allowsAbstractReturnTypeAndIsEitherAbstractOrCanBeConstructed​(Type returnTypeImpl)
      • isAbstractReturnTypeAllowed

        private boolean isAbstractReturnTypeAllowed()
      • initializeMappingReferencesIfNeeded

        private void initializeMappingReferencesIfNeeded​(Type resultTypeToMap)
      • isBuilderRequired

        private boolean isBuilderRequired()
        Returns:
        builder is required when there is a returnTypeBuilder and the mapping method is not update method. However, builder is also required when there is a returnTypeBuilder, the mapping target is the builder and builder is not assignable to the return type (so without building).
      • shouldCallFinalizerMethod

        private boolean shouldCallFinalizerMethod​(Type returnTypeToConstruct)
      • handleUnprocessedDefinedTargets

        private void handleUnprocessedDefinedTargets()
        If there were nested defined targets that have not been handled. Then we need to process them at the end.
      • handleUnmappedConstructorProperties

        private void handleUnmappedConstructorProperties()
      • sortPropertyMappingsByDependencies

        private void sortPropertyMappingsByDependencies()
        Sources the given mappings as per the dependency relationships given via dependsOn(). If a cycle is detected, an error is reported.
      • canResultTypeFromBeanMappingBeConstructed

        private boolean canResultTypeFromBeanMappingBeConstructed​(Type resultType)
      • canReturnTypeBeConstructed

        private boolean canReturnTypeBeConstructed​(Type returnType)
      • isReturnTypeAbstractOrCanBeConstructed

        private boolean isReturnTypeAbstractOrCanBeConstructed​(Type returnType)
      • initializeFactoryMethod

        private void initializeFactoryMethod​(Type returnTypeImpl,
                                             SelectionParameters selectionParameters)
        Find a factory method for a return type or for a builder.
        Parameters:
        returnTypeImpl - the return type implementation to construct
      • createConstructorAccessor

        private Accessor createConstructorAccessor​(javax.lang.model.element.Element element,
                                                   javax.lang.model.type.TypeMirror accessedType,
                                                   java.lang.String parameterName)
      • hasDefaultAnnotationFromAnyPackage

        private boolean hasDefaultAnnotationFromAnyPackage​(javax.lang.model.element.Element element)
      • getArrayValues

        private java.util.List<java.lang.String> getArrayValues​(javax.lang.model.element.AnnotationValue av)
      • getValueAsList

        private java.util.List<javax.lang.model.element.AnnotationValue> getValueAsList​(javax.lang.model.element.AnnotationValue av)
      • handleDefinedMappings

        private boolean handleDefinedMappings​(Type resultTypeToMap)
        Iterates over all defined mapping methods (@Mapping(s)), either directly given or inherited from the inverse mapping method.

        If a match is found between a defined source (constant, expression, ignore or source) the mapping is removed from the remaining target properties.

        It is furthermore checked whether the given mappings are correct. When an error occurs, the method continues in search of more problems.

        Parameters:
        resultTypeToMap - the type in which the defined target properties are defined
      • handleDefinedNestedTargetMapping

        private boolean handleDefinedNestedTargetMapping​(java.util.Set<java.lang.String> handledTargets,
                                                         Type resultTypeToMap)
      • handleDefinedMapping

        private boolean handleDefinedMapping​(MappingReference mappingRef,
                                             Type resultTypeToMap,
                                             java.util.Set<java.lang.String> handledTargets)
      • applyTargetThisMapping

        private void applyTargetThisMapping()
        When target this mapping present, iterates over unprocessed targets.

        When a target property matches its name with the (nested) source property, it is added to the list if and only if it is an unprocessed target property. duplicates will be handled by applyPropertyNameBasedMapping(List)

      • applyPropertyNameBasedMapping

        private void applyPropertyNameBasedMapping()
        Iterates over all target properties and all source parameters.

        When a property name match occurs, the remainder will be checked for duplicates. Matches will be removed from the set of remaining target properties.

      • applyPropertyNameBasedMapping

        private void applyPropertyNameBasedMapping​(java.util.List<SourceReference> sourceReferences)
        Iterates over all target properties and all source parameters.

        When a property name match occurs, the remainder will be checked for duplicates. Matches will be removed from the set of remaining target properties.

      • applyParameterNameBasedMapping

        private void applyParameterNameBasedMapping()
      • getSourceRefByTargetName

        private SourceReference getSourceRefByTargetName​(Parameter sourceParameter,
                                                         java.lang.String targetPropertyName)
      • extractMappingReferences

        private MappingReferences extractMappingReferences​(java.lang.String targetProperty,
                                                           boolean restrictToDefinedMappings)
      • reportErrorForUnmappedTargetPropertiesIfRequired

        private void reportErrorForUnmappedTargetPropertiesIfRequired()
      • reportErrorForUnmappedSourcePropertiesIfRequired

        private void reportErrorForUnmappedSourcePropertiesIfRequired()
      • reportErrorForMissingIgnoredSourceProperties

        private void reportErrorForMissingIgnoredSourceProperties()
      • reportErrorForUnusedSourceParameters

        private void reportErrorForUnusedSourceParameters()