Class GetterWrapperForCollectionsAndMaps
java.lang.Object
org.mapstruct.ap.internal.writer.FreeMarkerWritable
org.mapstruct.ap.internal.model.common.ModelElement
org.mapstruct.ap.internal.model.assignment.AssignmentWrapper
org.mapstruct.ap.internal.model.assignment.WrapperForCollectionsAndMaps
org.mapstruct.ap.internal.model.assignment.GetterWrapperForCollectionsAndMaps
- All Implemented Interfaces:
Assignment,Writable
This wrapper handles the situation were an assignment must be done via a target getter method because there
is no setter available.
The wrapper checks if there is a collection or map initialized on the target bean (not null). If so it uses the
addAll (for collections) or putAll (for maps). The collection / map is cleared in case of a pre-existing target
MappingTargetbefore adding the source entries. The goal is that the same collection / map
is used as target.
Nothing can be added if the getter on the target returns null.- Author:
- Sjaak Derksen
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.mapstruct.ap.internal.model.common.Assignment
Assignment.AssignmentTypeNested classes/interfaces inherited from interface org.mapstruct.ap.internal.writer.Writable
Writable.Context -
Field Summary
Fields inherited from class org.mapstruct.ap.internal.model.assignment.AssignmentWrapper
fieldAssignment -
Constructor Summary
ConstructorsConstructorDescriptionGetterWrapperForCollectionsAndMaps(Assignment decoratedAssignment, List<Type> thrownTypesToExclude, Type targetType, boolean fieldAssignment) GetterWrapperForCollectionsAndMaps(Assignment decoratedAssignment, List<Type> thrownTypesToExclude, Type targetType, org.mapstruct.ap.internal.gem.NullValuePropertyMappingStrategyGem nvpms, boolean fieldAssignment) -
Method Summary
Modifier and TypeMethodDescriptionReturns a set containing thoseTypes referenced by this model element for which an import statement needs to be declared.booleanMethods inherited from class org.mapstruct.ap.internal.model.assignment.WrapperForCollectionsAndMaps
getNullCheckLocalVarName, getNullCheckLocalVarType, getThrownTypesMethods inherited from class org.mapstruct.ap.internal.model.assignment.AssignmentWrapper
createUniqueVarName, getAssignment, getSourceLocalVarName, getSourceLoopVarName, getSourceParameterName, getSourcePresenceCheckerReference, getSourceReference, getSourceType, getType, isCallingUpdateMethod, isFieldAssignment, isSourceReferenceParameter, setAssignment, setSourceLocalVarName, setSourceLoopVarNameMethods inherited from class org.mapstruct.ap.internal.writer.FreeMarkerWritable
getTemplateName, getTemplateNameForClass, write
-
Constructor Details
-
GetterWrapperForCollectionsAndMaps
public GetterWrapperForCollectionsAndMaps(Assignment decoratedAssignment, List<Type> thrownTypesToExclude, Type targetType, boolean fieldAssignment) -
GetterWrapperForCollectionsAndMaps
public GetterWrapperForCollectionsAndMaps(Assignment decoratedAssignment, List<Type> thrownTypesToExclude, Type targetType, org.mapstruct.ap.internal.gem.NullValuePropertyMappingStrategyGem nvpms, boolean fieldAssignment) - Parameters:
decoratedAssignment- source RHSthrownTypesToExclude- set of types to exclude from re-throwingtargetType- the target typefieldAssignment- true when this the assignment is to a field rather than via accessors
-
-
Method Details
-
getImportTypes
Description copied from class:ModelElementReturns a set containing thoseTypes referenced by this model element for which an import statement needs to be declared.- Specified by:
getImportTypesin interfaceAssignment- Overrides:
getImportTypesin classAssignmentWrapper- Returns:
- A set with type referenced by this model element. Must not be
null.
-
isIgnoreMapNull
public boolean isIgnoreMapNull()
-