combined = new HashSet<>( importTypes );
+ combined.addAll( assignmentImports );
+ return combined;
+ }
+ }
return importTypes;
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/ArrayCopyWrapper.java b/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/ArrayCopyWrapper.java
index 6b623f7e39..9828817714 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/ArrayCopyWrapper.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/ArrayCopyWrapper.java
@@ -33,7 +33,9 @@ public ArrayCopyWrapper(Assignment rhs,
super( rhs, fieldAssignment );
this.arraysType = arraysType;
this.targetType = targetType;
- rhs.setSourceLocalVarName( rhs.createUniqueVarName( targetPropertyName ) );
+ if ( rhs.getSourceLocalVarName() == null ) {
+ rhs.setSourceLocalVarName( rhs.createUniqueVarName( targetPropertyName ) );
+ }
this.setExplicitlyToDefault = setExplicitlyToDefault;
this.setExplicitlyToNull = setExplicitlyToNull;
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/SourceRHS.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/SourceRHS.java
index b4d422c797..56ef3bb3d3 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/SourceRHS.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/SourceRHS.java
@@ -7,6 +7,7 @@
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
@@ -17,7 +18,7 @@
/**
* SourceRHS Assignment. Right Hand Side (RHS), source part of the assignment.
- *
+ *
* This class contains all information on the source side of an assignment needed for common use in the mapping.
*
* @author Sjaak Derksen
@@ -35,12 +36,12 @@ public class SourceRHS extends ModelElement implements Assignment {
private final String sourceParameterName;
public SourceRHS(String sourceReference, Type sourceType, Set existingVariableNames,
- String sourceErrorMessagePart ) {
+ String sourceErrorMessagePart) {
this( sourceReference, sourceReference, null, sourceType, existingVariableNames, sourceErrorMessagePart );
}
public SourceRHS(String sourceParameterName, String sourceReference, PresenceCheck sourcePresenceCheckerReference,
- Type sourceType, Set existingVariableNames, String sourceErrorMessagePart ) {
+ Type sourceType, Set existingVariableNames, String sourceErrorMessagePart) {
this.sourceReference = sourceReference;
this.sourceType = sourceType;
this.existingVariableNames = existingVariableNames;
@@ -100,6 +101,14 @@ public void setSourceLoopVarName(String sourceLoopVarName) {
@Override
public Set getImportTypes() {
+ if ( sourceLocalVarName != null ) {
+ Set imports = new HashSet<>();
+ imports.add( sourceType );
+ if ( sourcePresenceCheckerReference != null ) {
+ imports.addAll( sourcePresenceCheckerReference.getImportTypes() );
+ }
+ return imports;
+ }
if ( sourcePresenceCheckerReference != null ) {
return sourcePresenceCheckerReference.getImportTypes();
}
@@ -113,7 +122,7 @@ public List getThrownTypes() {
}
@Override
- public void setAssignment( Assignment assignment ) {
+ public void setAssignment(Assignment assignment) {
throw new UnsupportedOperationException( "Not supported." );
}
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java
index af3d293f7d..c87631e39f 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java
@@ -23,8 +23,9 @@ public ContainerBeanDto mapWithMapMapping(ContainerBean containerBean, Container
return containerBeanDto;
}
+ Map beanMap = containerBean.getBeanMap();
if ( containerBeanDto.getBeanMap() != null ) {
- Map map = stringContainerBeanMapToStringContainerBeanDtoMap( containerBean.getBeanMap() );
+ Map map = stringContainerBeanMapToStringContainerBeanDtoMap( beanMap );
if ( map != null ) {
containerBeanDto.getBeanMap().clear();
containerBeanDto.getBeanMap().putAll( map );
@@ -34,7 +35,7 @@ public ContainerBeanDto mapWithMapMapping(ContainerBean containerBean, Container
}
}
else {
- Map map = stringContainerBeanMapToStringContainerBeanDtoMap( containerBean.getBeanMap() );
+ Map map = stringContainerBeanMapToStringContainerBeanDtoMap( beanMap );
if ( map != null ) {
containerBeanDto.setBeanMap( map );
}
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java
index 9d118122bb..3f858486c2 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java
@@ -59,56 +59,61 @@ public void update(DtoWithPresenceCheck source, Domain target) {
return;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
if ( source.hasStrings() ) {
target.getStrings().clear();
- target.getStrings().addAll( source.getStrings() );
+ target.getStrings().addAll( strings );
}
}
else {
if ( source.hasStrings() ) {
- List list = source.getStrings();
+ List list = strings;
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
if ( source.hasStrings() ) {
target.getLongs().clear();
- target.getLongs().addAll( stringListToLongSet( source.getStrings() ) );
+ target.getLongs().addAll( stringListToLongSet( strings1 ) );
}
}
else {
if ( source.hasStrings() ) {
- target.setLongs( stringListToLongSet( source.getStrings() ) );
+ target.setLongs( stringListToLongSet( strings1 ) );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getStringsInitialized().clear();
- target.getStringsInitialized().addAll( source.getStringsInitialized() );
+ target.getStringsInitialized().addAll( stringsInitialized );
}
}
else {
if ( source.hasStringsInitialized() ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getLongsInitialized().clear();
- target.getLongsInitialized().addAll( stringListToLongSet( source.getStringsInitialized() ) );
+ target.getLongsInitialized().addAll( stringListToLongSet( stringsInitialized1 ) );
}
}
else {
if ( source.hasStringsInitialized() ) {
- target.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) );
+ target.setLongsInitialized( stringListToLongSet( stringsInitialized1 ) );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
if ( source.hasStringsWithDefault() ) {
target.getStringsWithDefault().clear();
- target.getStringsWithDefault().addAll( source.getStringsWithDefault() );
+ target.getStringsWithDefault().addAll( stringsWithDefault );
}
else {
target.setStringsWithDefault( helper.toList( "3" ) );
@@ -116,7 +121,7 @@ public void update(DtoWithPresenceCheck source, Domain target) {
}
else {
if ( source.hasStringsWithDefault() ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
else {
@@ -131,56 +136,61 @@ public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
return target;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
if ( source.hasStrings() ) {
target.getStrings().clear();
- target.getStrings().addAll( source.getStrings() );
+ target.getStrings().addAll( strings );
}
}
else {
if ( source.hasStrings() ) {
- List list = source.getStrings();
+ List list = strings;
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
if ( source.hasStrings() ) {
target.getLongs().clear();
- target.getLongs().addAll( stringListToLongSet( source.getStrings() ) );
+ target.getLongs().addAll( stringListToLongSet( strings1 ) );
}
}
else {
if ( source.hasStrings() ) {
- target.setLongs( stringListToLongSet( source.getStrings() ) );
+ target.setLongs( stringListToLongSet( strings1 ) );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getStringsInitialized().clear();
- target.getStringsInitialized().addAll( source.getStringsInitialized() );
+ target.getStringsInitialized().addAll( stringsInitialized );
}
}
else {
if ( source.hasStringsInitialized() ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getLongsInitialized().clear();
- target.getLongsInitialized().addAll( stringListToLongSet( source.getStringsInitialized() ) );
+ target.getLongsInitialized().addAll( stringListToLongSet( stringsInitialized1 ) );
}
}
else {
if ( source.hasStringsInitialized() ) {
- target.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) );
+ target.setLongsInitialized( stringListToLongSet( stringsInitialized1 ) );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
if ( source.hasStringsWithDefault() ) {
target.getStringsWithDefault().clear();
- target.getStringsWithDefault().addAll( source.getStringsWithDefault() );
+ target.getStringsWithDefault().addAll( stringsWithDefault );
}
else {
target.setStringsWithDefault( helper.toList( "3" ) );
@@ -188,7 +198,7 @@ public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
}
else {
if ( source.hasStringsWithDefault() ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
else {
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java
index 99a731b04c..94bfea8ad7 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java
@@ -52,8 +52,9 @@ public Domain create(Dto source) {
public void update(Dto source, Domain target) {
if ( source != null ) {
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -63,7 +64,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
@@ -71,8 +72,9 @@ public void update(Dto source, Domain target) {
target.setStrings( new LinkedHashSet<>() );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -82,7 +84,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
@@ -90,8 +92,9 @@ public void update(Dto source, Domain target) {
target.setLongs( new LinkedHashSet<>() );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.getStringsInitialized().clear();
target.getStringsInitialized().addAll( list1 );
@@ -101,7 +104,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
@@ -109,8 +112,9 @@ public void update(Dto source, Domain target) {
target.setStringsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.getLongsInitialized().clear();
target.getLongsInitialized().addAll( set1 );
@@ -120,7 +124,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.setLongsInitialized( set1 );
}
@@ -128,8 +132,9 @@ public void update(Dto source, Domain target) {
target.setLongsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.getStringsWithDefault().clear();
target.getStringsWithDefault().addAll( list2 );
@@ -139,7 +144,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
@@ -154,8 +159,9 @@ public void update(Dto source, Domain target) {
public Domain updateWithReturn(Dto source, Domain target) {
if ( source != null ) {
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -165,7 +171,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
@@ -173,8 +179,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setStrings( new LinkedHashSet<>() );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -184,7 +191,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
@@ -192,8 +199,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setLongs( new LinkedHashSet<>() );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.getStringsInitialized().clear();
target.getStringsInitialized().addAll( list1 );
@@ -203,7 +211,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
@@ -211,8 +219,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setStringsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.getLongsInitialized().clear();
target.getLongsInitialized().addAll( set1 );
@@ -222,7 +231,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.setLongsInitialized( set1 );
}
@@ -230,8 +239,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setLongsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.getStringsWithDefault().clear();
target.getStringsWithDefault().addAll( list2 );
@@ -241,7 +251,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java
index 47e7c5dbfe..1f7561a707 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java
@@ -55,8 +55,9 @@ public void update(Dto source, Domain target) {
return;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -66,13 +67,14 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -82,13 +84,14 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.getStringsInitialized().clear();
target.getStringsInitialized().addAll( list1 );
@@ -98,13 +101,14 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.getLongsInitialized().clear();
target.getLongsInitialized().addAll( set1 );
@@ -114,13 +118,14 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.setLongsInitialized( set1 );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.getStringsWithDefault().clear();
target.getStringsWithDefault().addAll( list2 );
@@ -130,7 +135,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
@@ -146,8 +151,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
return target;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -157,13 +163,14 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -173,13 +180,14 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.getStringsInitialized().clear();
target.getStringsInitialized().addAll( list1 );
@@ -189,13 +197,14 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.getLongsInitialized().clear();
target.getLongsInitialized().addAll( set1 );
@@ -205,13 +214,14 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.setLongsInitialized( set1 );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.getStringsWithDefault().clear();
target.getStringsWithDefault().addAll( list2 );
@@ -221,7 +231,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java
index dd90dd2b26..254de0b6ed 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java
@@ -59,56 +59,61 @@ public void update(DtoWithPresenceCheck source, Domain target) {
return;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
if ( source.hasStrings() ) {
target.getStrings().clear();
- target.getStrings().addAll( source.getStrings() );
+ target.getStrings().addAll( strings );
}
}
else {
if ( source.hasStrings() ) {
- List list = source.getStrings();
+ List list = strings;
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
if ( source.hasStrings() ) {
target.getLongs().clear();
- target.getLongs().addAll( stringListToLongSet( source.getStrings() ) );
+ target.getLongs().addAll( stringListToLongSet( strings1 ) );
}
}
else {
if ( source.hasStrings() ) {
- target.setLongs( stringListToLongSet( source.getStrings() ) );
+ target.setLongs( stringListToLongSet( strings1 ) );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getStringsInitialized().clear();
- target.getStringsInitialized().addAll( source.getStringsInitialized() );
+ target.getStringsInitialized().addAll( stringsInitialized );
}
}
else {
if ( source.hasStringsInitialized() ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getLongsInitialized().clear();
- target.getLongsInitialized().addAll( stringListToLongSet( source.getStringsInitialized() ) );
+ target.getLongsInitialized().addAll( stringListToLongSet( stringsInitialized1 ) );
}
}
else {
if ( source.hasStringsInitialized() ) {
- target.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) );
+ target.setLongsInitialized( stringListToLongSet( stringsInitialized1 ) );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
if ( source.hasStringsWithDefault() ) {
target.getStringsWithDefault().clear();
- target.getStringsWithDefault().addAll( source.getStringsWithDefault() );
+ target.getStringsWithDefault().addAll( stringsWithDefault );
}
else {
target.setStringsWithDefault( helper.toList( "3" ) );
@@ -116,7 +121,7 @@ public void update(DtoWithPresenceCheck source, Domain target) {
}
else {
if ( source.hasStringsWithDefault() ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
else {
@@ -131,56 +136,61 @@ public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
return target;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
if ( source.hasStrings() ) {
target.getStrings().clear();
- target.getStrings().addAll( source.getStrings() );
+ target.getStrings().addAll( strings );
}
}
else {
if ( source.hasStrings() ) {
- List list = source.getStrings();
+ List list = strings;
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
if ( source.hasStrings() ) {
target.getLongs().clear();
- target.getLongs().addAll( stringListToLongSet( source.getStrings() ) );
+ target.getLongs().addAll( stringListToLongSet( strings1 ) );
}
}
else {
if ( source.hasStrings() ) {
- target.setLongs( stringListToLongSet( source.getStrings() ) );
+ target.setLongs( stringListToLongSet( strings1 ) );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getStringsInitialized().clear();
- target.getStringsInitialized().addAll( source.getStringsInitialized() );
+ target.getStringsInitialized().addAll( stringsInitialized );
}
}
else {
if ( source.hasStringsInitialized() ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getLongsInitialized().clear();
- target.getLongsInitialized().addAll( stringListToLongSet( source.getStringsInitialized() ) );
+ target.getLongsInitialized().addAll( stringListToLongSet( stringsInitialized1 ) );
}
}
else {
if ( source.hasStringsInitialized() ) {
- target.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) );
+ target.setLongsInitialized( stringListToLongSet( stringsInitialized1 ) );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
if ( source.hasStringsWithDefault() ) {
target.getStringsWithDefault().clear();
- target.getStringsWithDefault().addAll( source.getStringsWithDefault() );
+ target.getStringsWithDefault().addAll( stringsWithDefault );
}
else {
target.setStringsWithDefault( helper.toList( "3" ) );
@@ -188,7 +198,7 @@ public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
}
else {
if ( source.hasStringsWithDefault() ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
else {
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/conversion/numbers/SourceTargetMapperImpl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/conversion/numbers/SourceTargetMapperImpl.java
index 605b3a5baa..6202639b23 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/conversion/numbers/SourceTargetMapperImpl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/conversion/numbers/SourceTargetMapperImpl.java
@@ -6,6 +6,7 @@
package org.mapstruct.ap.test.conversion.numbers;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.ParseException;
@@ -18,8 +19,8 @@
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
- date = "2024-09-14T11:37:30+0300",
- comments = "version: , compiler: javac, environment: Java 21.0.2 (Amazon.com Inc.)"
+ date = "2026-06-05T15:54:34+0200",
+ comments = "version: , compiler: javac, environment: Java 21.0.2 (Oracle Corporation)"
)
public class SourceTargetMapperImpl implements SourceTargetMapper {
@@ -32,32 +33,39 @@ public Target sourceToTarget(Source source) {
Target target = new Target();
target.setI( new DecimalFormat( "##.00" ).format( source.getI() ) );
- if ( source.getIi() != null ) {
- target.setIi( new DecimalFormat( "##.00" ).format( source.getIi() ) );
+ Integer ii = source.getIi();
+ if ( ii != null ) {
+ target.setIi( new DecimalFormat( "##.00" ).format( ii ) );
}
target.setD( new DecimalFormat( "##.00" ).format( source.getD() ) );
- if ( source.getDd() != null ) {
- target.setDd( new DecimalFormat( "##.00" ).format( source.getDd() ) );
+ Double dd = source.getDd();
+ if ( dd != null ) {
+ target.setDd( new DecimalFormat( "##.00" ).format( dd ) );
}
target.setF( new DecimalFormat( "##.00" ).format( source.getF() ) );
- if ( source.getFf() != null ) {
- target.setFf( new DecimalFormat( "##.00" ).format( source.getFf() ) );
+ Float ff = source.getFf();
+ if ( ff != null ) {
+ target.setFf( new DecimalFormat( "##.00" ).format( ff ) );
}
target.setL( new DecimalFormat( "##.00" ).format( source.getL() ) );
- if ( source.getLl() != null ) {
- target.setLl( new DecimalFormat( "##.00" ).format( source.getLl() ) );
+ Long ll = source.getLl();
+ if ( ll != null ) {
+ target.setLl( new DecimalFormat( "##.00" ).format( ll ) );
}
target.setB( new DecimalFormat( "##.00" ).format( source.getB() ) );
- if ( source.getBb() != null ) {
- target.setBb( new DecimalFormat( "##.00" ).format( source.getBb() ) );
+ Byte bb = source.getBb();
+ if ( bb != null ) {
+ target.setBb( new DecimalFormat( "##.00" ).format( bb ) );
}
target.setComplex1( new DecimalFormat( "##0.##E0" ).format( source.getComplex1() ) );
target.setComplex2( new DecimalFormat( "$#.00" ).format( source.getComplex2() ) );
- if ( source.getBigDecimal1() != null ) {
- target.setBigDecimal1( createDecimalFormat( "#0.#E0" ).format( source.getBigDecimal1() ) );
+ BigDecimal bigDecimal1 = source.getBigDecimal1();
+ if ( bigDecimal1 != null ) {
+ target.setBigDecimal1( createDecimalFormat( "#0.#E0" ).format( bigDecimal1 ) );
}
- if ( source.getBigInteger1() != null ) {
- target.setBigInteger1( createDecimalFormat( "0.#############E0" ).format( source.getBigInteger1() ) );
+ BigInteger bigInteger1 = source.getBigInteger1();
+ if ( bigInteger1 != null ) {
+ target.setBigInteger1( createDecimalFormat( "0.#############E0" ).format( bigInteger1 ) );
}
return target;
@@ -72,32 +80,39 @@ public Target sourceToTargetWithCustomLocale(Source source) {
Target target = new Target();
target.setI( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getI() ) );
- if ( source.getIi() != null ) {
- target.setIi( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getIi() ) );
+ Integer ii = source.getIi();
+ if ( ii != null ) {
+ target.setIi( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( ii ) );
}
target.setD( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getD() ) );
- if ( source.getDd() != null ) {
- target.setDd( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getDd() ) );
+ Double dd = source.getDd();
+ if ( dd != null ) {
+ target.setDd( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( dd ) );
}
target.setF( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getF() ) );
- if ( source.getFf() != null ) {
- target.setFf( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getFf() ) );
+ Float ff = source.getFf();
+ if ( ff != null ) {
+ target.setFf( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( ff ) );
}
target.setL( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getL() ) );
- if ( source.getLl() != null ) {
- target.setLl( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getLl() ) );
+ Long ll = source.getLl();
+ if ( ll != null ) {
+ target.setLl( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( ll ) );
}
target.setB( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getB() ) );
- if ( source.getBb() != null ) {
- target.setBb( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getBb() ) );
+ Byte bb = source.getBb();
+ if ( bb != null ) {
+ target.setBb( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( bb ) );
}
target.setComplex1( new DecimalFormat( "##0.##E0", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getComplex1() ) );
target.setComplex2( new DecimalFormat( "$#.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).format( source.getComplex2() ) );
- if ( source.getBigDecimal1() != null ) {
- target.setBigDecimal1( createDecimalFormatWithLocale( "#0.#E0", Locale.forLanguageTag( "ru" ) ).format( source.getBigDecimal1() ) );
+ BigDecimal bigDecimal1 = source.getBigDecimal1();
+ if ( bigDecimal1 != null ) {
+ target.setBigDecimal1( createDecimalFormatWithLocale( "#0.#E0", Locale.forLanguageTag( "ru" ) ).format( bigDecimal1 ) );
}
- if ( source.getBigInteger1() != null ) {
- target.setBigInteger1( createDecimalFormatWithLocale( "0.#############E0", Locale.forLanguageTag( "ru" ) ).format( source.getBigInteger1() ) );
+ BigInteger bigInteger1 = source.getBigInteger1();
+ if ( bigInteger1 != null ) {
+ target.setBigInteger1( createDecimalFormatWithLocale( "0.#############E0", Locale.forLanguageTag( "ru" ) ).format( bigInteger1 ) );
}
return target;
@@ -112,112 +127,126 @@ public Source targetToSource(Target target) {
Source source = new Source();
try {
- if ( target.getI() != null ) {
- source.setI( new DecimalFormat( "##.00" ).parse( target.getI() ).intValue() );
+ String i = target.getI();
+ if ( i != null ) {
+ source.setI( new DecimalFormat( "##.00" ).parse( i ).intValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getIi() != null ) {
- source.setIi( new DecimalFormat( "##.00" ).parse( target.getIi() ).intValue() );
+ String ii = target.getIi();
+ if ( ii != null ) {
+ source.setIi( new DecimalFormat( "##.00" ).parse( ii ).intValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getD() != null ) {
- source.setD( new DecimalFormat( "##.00" ).parse( target.getD() ).doubleValue() );
+ String d = target.getD();
+ if ( d != null ) {
+ source.setD( new DecimalFormat( "##.00" ).parse( d ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getDd() != null ) {
- source.setDd( new DecimalFormat( "##.00" ).parse( target.getDd() ).doubleValue() );
+ String dd = target.getDd();
+ if ( dd != null ) {
+ source.setDd( new DecimalFormat( "##.00" ).parse( dd ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getF() != null ) {
- source.setF( new DecimalFormat( "##.00" ).parse( target.getF() ).floatValue() );
+ String f = target.getF();
+ if ( f != null ) {
+ source.setF( new DecimalFormat( "##.00" ).parse( f ).floatValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getFf() != null ) {
- source.setFf( new DecimalFormat( "##.00" ).parse( target.getFf() ).floatValue() );
+ String ff = target.getFf();
+ if ( ff != null ) {
+ source.setFf( new DecimalFormat( "##.00" ).parse( ff ).floatValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getL() != null ) {
- source.setL( new DecimalFormat( "##.00" ).parse( target.getL() ).longValue() );
+ String l = target.getL();
+ if ( l != null ) {
+ source.setL( new DecimalFormat( "##.00" ).parse( l ).longValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getLl() != null ) {
- source.setLl( new DecimalFormat( "##.00" ).parse( target.getLl() ).longValue() );
+ String ll = target.getLl();
+ if ( ll != null ) {
+ source.setLl( new DecimalFormat( "##.00" ).parse( ll ).longValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getB() != null ) {
- source.setB( new DecimalFormat( "##.00" ).parse( target.getB() ).byteValue() );
+ String b = target.getB();
+ if ( b != null ) {
+ source.setB( new DecimalFormat( "##.00" ).parse( b ).byteValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getBb() != null ) {
- source.setBb( new DecimalFormat( "##.00" ).parse( target.getBb() ).byteValue() );
+ String bb = target.getBb();
+ if ( bb != null ) {
+ source.setBb( new DecimalFormat( "##.00" ).parse( bb ).byteValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getComplex1() != null ) {
- source.setComplex1( new DecimalFormat( "##0.##E0" ).parse( target.getComplex1() ).doubleValue() );
+ String complex1 = target.getComplex1();
+ if ( complex1 != null ) {
+ source.setComplex1( new DecimalFormat( "##0.##E0" ).parse( complex1 ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getComplex2() != null ) {
- source.setComplex2( new DecimalFormat( "$#.00" ).parse( target.getComplex2() ).doubleValue() );
+ String complex2 = target.getComplex2();
+ if ( complex2 != null ) {
+ source.setComplex2( new DecimalFormat( "$#.00" ).parse( complex2 ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getBigDecimal1() != null ) {
- source.setBigDecimal1( (BigDecimal) createDecimalFormat( "#0.#E0" ).parse( target.getBigDecimal1() ) );
+ String bigDecimal1 = target.getBigDecimal1();
+ if ( bigDecimal1 != null ) {
+ source.setBigDecimal1( (BigDecimal) createDecimalFormat( "#0.#E0" ).parse( bigDecimal1 ) );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getBigInteger1() != null ) {
- source.setBigInteger1( ( (BigDecimal) createDecimalFormat( "0.#############E0" ).parse( target.getBigInteger1() ) ).toBigInteger() );
+ String bigInteger1 = target.getBigInteger1();
+ if ( bigInteger1 != null ) {
+ source.setBigInteger1( ( (BigDecimal) createDecimalFormat( "0.#############E0" ).parse( bigInteger1 ) ).toBigInteger() );
}
}
catch ( ParseException e ) {
@@ -236,112 +265,126 @@ public Source targetToSourceWithCustomLocale(Target target) {
Source source = new Source();
try {
- if ( target.getI() != null ) {
- source.setI( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getI() ).intValue() );
+ String i = target.getI();
+ if ( i != null ) {
+ source.setI( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( i ).intValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getIi() != null ) {
- source.setIi( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getIi() ).intValue() );
+ String ii = target.getIi();
+ if ( ii != null ) {
+ source.setIi( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( ii ).intValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getD() != null ) {
- source.setD( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getD() ).doubleValue() );
+ String d = target.getD();
+ if ( d != null ) {
+ source.setD( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( d ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getDd() != null ) {
- source.setDd( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getDd() ).doubleValue() );
+ String dd = target.getDd();
+ if ( dd != null ) {
+ source.setDd( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( dd ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getF() != null ) {
- source.setF( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getF() ).floatValue() );
+ String f = target.getF();
+ if ( f != null ) {
+ source.setF( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( f ).floatValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getFf() != null ) {
- source.setFf( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getFf() ).floatValue() );
+ String ff = target.getFf();
+ if ( ff != null ) {
+ source.setFf( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( ff ).floatValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getL() != null ) {
- source.setL( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getL() ).longValue() );
+ String l = target.getL();
+ if ( l != null ) {
+ source.setL( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( l ).longValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getLl() != null ) {
- source.setLl( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getLl() ).longValue() );
+ String ll = target.getLl();
+ if ( ll != null ) {
+ source.setLl( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( ll ).longValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getB() != null ) {
- source.setB( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getB() ).byteValue() );
+ String b = target.getB();
+ if ( b != null ) {
+ source.setB( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( b ).byteValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getBb() != null ) {
- source.setBb( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getBb() ).byteValue() );
+ String bb = target.getBb();
+ if ( bb != null ) {
+ source.setBb( new DecimalFormat( "##.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( bb ).byteValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getComplex1() != null ) {
- source.setComplex1( new DecimalFormat( "##0.##E0", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getComplex1() ).doubleValue() );
+ String complex1 = target.getComplex1();
+ if ( complex1 != null ) {
+ source.setComplex1( new DecimalFormat( "##0.##E0", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( complex1 ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getComplex2() != null ) {
- source.setComplex2( new DecimalFormat( "$#.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( target.getComplex2() ).doubleValue() );
+ String complex2 = target.getComplex2();
+ if ( complex2 != null ) {
+ source.setComplex2( new DecimalFormat( "$#.00", DecimalFormatSymbols.getInstance( Locale.forLanguageTag( "ru " ) ) ).parse( complex2 ).doubleValue() );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getBigDecimal1() != null ) {
- source.setBigDecimal1( (BigDecimal) createDecimalFormatWithLocale( "#0.#E0", Locale.forLanguageTag( "ru" ) ).parse( target.getBigDecimal1() ) );
+ String bigDecimal1 = target.getBigDecimal1();
+ if ( bigDecimal1 != null ) {
+ source.setBigDecimal1( (BigDecimal) createDecimalFormatWithLocale( "#0.#E0", Locale.forLanguageTag( "ru" ) ).parse( bigDecimal1 ) );
}
}
catch ( ParseException e ) {
throw new RuntimeException( e );
}
try {
- if ( target.getBigInteger1() != null ) {
- source.setBigInteger1( ( (BigDecimal) createDecimalFormatWithLocale( "0.#############E0", Locale.forLanguageTag( "ru" ) ).parse( target.getBigInteger1() ) ).toBigInteger() );
+ String bigInteger1 = target.getBigInteger1();
+ if ( bigInteger1 != null ) {
+ source.setBigInteger1( ( (BigDecimal) createDecimalFormatWithLocale( "0.#############E0", Locale.forLanguageTag( "ru" ) ).parse( bigInteger1 ) ).toBigInteger() );
}
}
catch ( ParseException e ) {
diff --git a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java
index f34495cb28..bedfc81450 100644
--- a/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java
+++ b/processor/src/test/resources/fixtures/21/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java
@@ -25,11 +25,12 @@ public void toCompanyEntity(UnmappableCompanyDto dto, CompanyEntity entity) {
}
entity.setName( dto.getName() );
- if ( dto.getDepartment() != null ) {
+ UnmappableDepartmentDto department = dto.getDepartment();
+ if ( department != null ) {
if ( entity.getDepartment() == null ) {
entity.setDepartment( departmentEntityFactory.createDepartmentEntity() );
}
- unmappableDepartmentDtoToDepartmentEntity( dto.getDepartment(), entity.getDepartment() );
+ unmappableDepartmentDtoToDepartmentEntity( department, entity.getDepartment() );
}
else {
entity.setDepartment( null );
@@ -100,8 +101,9 @@ protected void unmappableDepartmentDtoToDepartmentEntity(UnmappableDepartmentDto
}
mappingTarget.setName( unmappableDepartmentDto.getName() );
+ Map secretaryToEmployee = unmappableDepartmentDto.getSecretaryToEmployee();
if ( mappingTarget.getSecretaryToEmployee() != null ) {
- Map map = secretaryDtoEmployeeDtoMapToSecretaryEntityEmployeeEntityMap( unmappableDepartmentDto.getSecretaryToEmployee() );
+ Map map = secretaryDtoEmployeeDtoMapToSecretaryEntityEmployeeEntityMap( secretaryToEmployee );
if ( map != null ) {
mappingTarget.getSecretaryToEmployee().clear();
mappingTarget.getSecretaryToEmployee().putAll( map );
@@ -111,7 +113,7 @@ protected void unmappableDepartmentDtoToDepartmentEntity(UnmappableDepartmentDto
}
}
else {
- Map map = secretaryDtoEmployeeDtoMapToSecretaryEntityEmployeeEntityMap( unmappableDepartmentDto.getSecretaryToEmployee() );
+ Map map = secretaryDtoEmployeeDtoMapToSecretaryEntityEmployeeEntityMap( secretaryToEmployee );
if ( map != null ) {
mappingTarget.setSecretaryToEmployee( map );
}
diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1576/java8/Issue1576MapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1576/java8/Issue1576MapperImpl.java
index f15d1b6830..5ada15b026 100644
--- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1576/java8/Issue1576MapperImpl.java
+++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1576/java8/Issue1576MapperImpl.java
@@ -10,12 +10,13 @@
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
-import javax.annotation.Generated;
+import java.util.Date;
+import javax.annotation.processing.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
- date = "2018-11-05T21:40:12+0100",
- comments = "version: , compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
+ date = "2026-06-05T15:53:43+0200",
+ comments = "version: , compiler: Eclipse JDT (Batch) 3.20.0.v20191203-2131, environment: Java 21.0.2 (Oracle Corporation)"
)
public class Issue1576MapperImpl implements Issue1576Mapper {
@@ -27,20 +28,25 @@ public Target map(Source source) {
Target target = new Target();
- if ( source.getLocalDateTime() != null ) {
- target.setLocalDateTime( LocalDateTime.ofInstant( source.getLocalDateTime().toInstant(), ZoneId.of( "UTC" ) ) );
+ Date localDateTime = source.getLocalDateTime();
+ if ( localDateTime != null ) {
+ target.setLocalDateTime( LocalDateTime.ofInstant( localDateTime.toInstant(), ZoneId.of( "UTC" ) ) );
}
- if ( source.getLocalDate() != null ) {
- target.setLocalDate( LocalDateTime.ofInstant( source.getLocalDate().toInstant(), ZoneOffset.UTC ).toLocalDate() );
+ Date localDate = source.getLocalDate();
+ if ( localDate != null ) {
+ target.setLocalDate( LocalDateTime.ofInstant( localDate.toInstant(), ZoneOffset.UTC ).toLocalDate() );
}
- if ( source.getLocalTime() != null ) {
- target.setLocalTime( LocalTime.parse( source.getLocalTime() ) );
+ String localTime = source.getLocalTime();
+ if ( localTime != null ) {
+ target.setLocalTime( LocalTime.parse( localTime ) );
}
- if ( source.getZonedDateTime() != null ) {
- target.setZonedDateTime( ZonedDateTime.ofInstant( source.getZonedDateTime().toInstant(), ZoneId.systemDefault() ) );
+ Date zonedDateTime = source.getZonedDateTime();
+ if ( zonedDateTime != null ) {
+ target.setZonedDateTime( ZonedDateTime.ofInstant( zonedDateTime.toInstant(), ZoneId.systemDefault() ) );
}
- if ( source.getInstant() != null ) {
- target.setInstant( source.getInstant().toInstant() );
+ Date instant = source.getInstant();
+ if ( instant != null ) {
+ target.setInstant( instant.toInstant() );
}
return target;
diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1685/UserMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1685/UserMapperImpl.java
index b7cb63eb97..231152fb73 100644
--- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1685/UserMapperImpl.java
+++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1685/UserMapperImpl.java
@@ -8,12 +8,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import javax.annotation.Generated;
+import javax.annotation.processing.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
- date = "2019-01-27T12:40:32+0100",
- comments = "version: , compiler: Eclipse JDT (Batch) 1.2.100.v20160418-1457, environment: Java 1.8.0_181 (Oracle Corporation)"
+ date = "2026-06-05T14:55:19+0200",
+ comments = "version: , compiler: javac, environment: Java 21.0.11 (IBM Corporation)"
)
public class UserMapperImpl implements UserMapper {
@@ -52,9 +52,9 @@ public void updateUserFromUserDTO(UserDTO userDTO, User user) {
user.addPreference( contactDataDTOPreference );
}
}
- String[] settings1 = userDTOContactDataDTOSettings( userDTO );
- if ( settings1 != null ) {
- user.setSettings( Arrays.copyOf( settings1, settings1.length ) );
+ String[] settings = userDTOContactDataDTOSettings( userDTO );
+ if ( settings != null ) {
+ user.setSettings( Arrays.copyOf( settings, settings.length ) );
}
else {
user.setSettings( null );
@@ -86,12 +86,13 @@ public void updateUserFromUserAndIgnoreDTO(UserDTO userDTO, User user) {
user.addPreference( contactDataDTOPreference );
}
}
- String[] settings1 = userDTOContactDataDTOSettings( userDTO );
- if ( settings1 != null ) {
- user.setSettings( Arrays.copyOf( settings1, settings1.length ) );
+ String[] settings = userDTOContactDataDTOSettings( userDTO );
+ if ( settings != null ) {
+ user.setSettings( Arrays.copyOf( settings, settings.length ) );
}
- if ( userDTO.getName() != null ) {
- user.setName( userDTO.getName() );
+ String name = userDTO.getName();
+ if ( name != null ) {
+ user.setName( name );
}
}
@@ -128,15 +129,16 @@ public void updateUserFromUserAndDefaultDTO(UserDTO userDTO, User user) {
user.addPreference( contactDataDTOPreference );
}
}
- String[] settings1 = userDTOContactDataDTOSettings( userDTO );
- if ( settings1 != null ) {
- user.setSettings( Arrays.copyOf( settings1, settings1.length ) );
+ String[] settings = userDTOContactDataDTOSettings( userDTO );
+ if ( settings != null ) {
+ user.setSettings( Arrays.copyOf( settings, settings.length ) );
}
else {
user.setSettings( new String[0] );
}
- if ( userDTO.getName() != null ) {
- user.setName( userDTO.getName() );
+ String name = userDTO.getName();
+ if ( name != null ) {
+ user.setName( name );
}
else {
user.setName( "" );
@@ -151,8 +153,9 @@ protected ContactDataDTO userToContactDataDTO(User user) {
ContactDataDTO contactDataDTO = new ContactDataDTO();
contactDataDTO.setEmail( user.getEmail() );
- if ( user.getPhone() != null ) {
- contactDataDTO.setPhone( String.valueOf( user.getPhone() ) );
+ Integer phone = user.getPhone();
+ if ( phone != null ) {
+ contactDataDTO.setPhone( String.valueOf( phone ) );
}
contactDataDTO.setAddress( user.getAddress() );
List list = user.getPreferences();
diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java
index 3ded8ca7bf..564598fa15 100644
--- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java
+++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_3591/ContainerBeanMapperImpl.java
@@ -23,8 +23,9 @@ public ContainerBeanDto mapWithMapMapping(ContainerBean containerBean, Container
return containerBeanDto;
}
+ Map beanMap = containerBean.getBeanMap();
if ( containerBeanDto.getBeanMap() != null ) {
- Map map = stringContainerBeanMapToStringContainerBeanDtoMap( containerBean.getBeanMap() );
+ Map map = stringContainerBeanMapToStringContainerBeanDtoMap( beanMap );
if ( map != null ) {
containerBeanDto.getBeanMap().clear();
containerBeanDto.getBeanMap().putAll( map );
@@ -34,7 +35,7 @@ public ContainerBeanDto mapWithMapMapping(ContainerBean containerBean, Container
}
}
else {
- Map map = stringContainerBeanMapToStringContainerBeanDtoMap( containerBean.getBeanMap() );
+ Map map = stringContainerBeanMapToStringContainerBeanDtoMap( beanMap );
if ( map != null ) {
containerBeanDto.setBeanMap( map );
}
diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java
index 5abb16122c..09b702c20f 100644
--- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java
+++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNcvsAlwaysMapperImpl.java
@@ -59,56 +59,61 @@ public void update(DtoWithPresenceCheck source, Domain target) {
return;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
if ( source.hasStrings() ) {
target.getStrings().clear();
- target.getStrings().addAll( source.getStrings() );
+ target.getStrings().addAll( strings );
}
}
else {
if ( source.hasStrings() ) {
- List list = source.getStrings();
+ List list = strings;
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
if ( source.hasStrings() ) {
target.getLongs().clear();
- target.getLongs().addAll( stringListToLongSet( source.getStrings() ) );
+ target.getLongs().addAll( stringListToLongSet( strings1 ) );
}
}
else {
if ( source.hasStrings() ) {
- target.setLongs( stringListToLongSet( source.getStrings() ) );
+ target.setLongs( stringListToLongSet( strings1 ) );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getStringsInitialized().clear();
- target.getStringsInitialized().addAll( source.getStringsInitialized() );
+ target.getStringsInitialized().addAll( stringsInitialized );
}
}
else {
if ( source.hasStringsInitialized() ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getLongsInitialized().clear();
- target.getLongsInitialized().addAll( stringListToLongSet( source.getStringsInitialized() ) );
+ target.getLongsInitialized().addAll( stringListToLongSet( stringsInitialized1 ) );
}
}
else {
if ( source.hasStringsInitialized() ) {
- target.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) );
+ target.setLongsInitialized( stringListToLongSet( stringsInitialized1 ) );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
if ( source.hasStringsWithDefault() ) {
target.getStringsWithDefault().clear();
- target.getStringsWithDefault().addAll( source.getStringsWithDefault() );
+ target.getStringsWithDefault().addAll( stringsWithDefault );
}
else {
target.setStringsWithDefault( helper.toList( "3" ) );
@@ -116,7 +121,7 @@ public void update(DtoWithPresenceCheck source, Domain target) {
}
else {
if ( source.hasStringsWithDefault() ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
else {
@@ -131,56 +136,61 @@ public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
return target;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
if ( source.hasStrings() ) {
target.getStrings().clear();
- target.getStrings().addAll( source.getStrings() );
+ target.getStrings().addAll( strings );
}
}
else {
if ( source.hasStrings() ) {
- List list = source.getStrings();
+ List list = strings;
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
if ( source.hasStrings() ) {
target.getLongs().clear();
- target.getLongs().addAll( stringListToLongSet( source.getStrings() ) );
+ target.getLongs().addAll( stringListToLongSet( strings1 ) );
}
}
else {
if ( source.hasStrings() ) {
- target.setLongs( stringListToLongSet( source.getStrings() ) );
+ target.setLongs( stringListToLongSet( strings1 ) );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getStringsInitialized().clear();
- target.getStringsInitialized().addAll( source.getStringsInitialized() );
+ target.getStringsInitialized().addAll( stringsInitialized );
}
}
else {
if ( source.hasStringsInitialized() ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
if ( source.hasStringsInitialized() ) {
target.getLongsInitialized().clear();
- target.getLongsInitialized().addAll( stringListToLongSet( source.getStringsInitialized() ) );
+ target.getLongsInitialized().addAll( stringListToLongSet( stringsInitialized1 ) );
}
}
else {
if ( source.hasStringsInitialized() ) {
- target.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) );
+ target.setLongsInitialized( stringListToLongSet( stringsInitialized1 ) );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
if ( source.hasStringsWithDefault() ) {
target.getStringsWithDefault().clear();
- target.getStringsWithDefault().addAll( source.getStringsWithDefault() );
+ target.getStringsWithDefault().addAll( stringsWithDefault );
}
else {
target.setStringsWithDefault( helper.toList( "3" ) );
@@ -188,7 +198,7 @@ public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
}
else {
if ( source.hasStringsWithDefault() ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
else {
diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java
index 2dbdf353a2..2dbb98982c 100644
--- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java
+++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsDefaultMapperImpl.java
@@ -52,8 +52,9 @@ public Domain create(Dto source) {
public void update(Dto source, Domain target) {
if ( source != null ) {
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -63,7 +64,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
@@ -71,8 +72,9 @@ public void update(Dto source, Domain target) {
target.setStrings( new LinkedHashSet<>() );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -82,7 +84,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
@@ -90,8 +92,9 @@ public void update(Dto source, Domain target) {
target.setLongs( new LinkedHashSet<>() );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.getStringsInitialized().clear();
target.getStringsInitialized().addAll( list1 );
@@ -101,7 +104,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
@@ -109,8 +112,9 @@ public void update(Dto source, Domain target) {
target.setStringsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.getLongsInitialized().clear();
target.getLongsInitialized().addAll( set1 );
@@ -120,7 +124,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.setLongsInitialized( set1 );
}
@@ -128,8 +132,9 @@ public void update(Dto source, Domain target) {
target.setLongsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.getStringsWithDefault().clear();
target.getStringsWithDefault().addAll( list2 );
@@ -139,7 +144,7 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
@@ -154,8 +159,9 @@ public void update(Dto source, Domain target) {
public Domain updateWithReturn(Dto source, Domain target) {
if ( source != null ) {
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -165,7 +171,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
@@ -173,8 +179,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setStrings( new LinkedHashSet<>() );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -184,7 +191,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
@@ -192,8 +199,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setLongs( new LinkedHashSet<>() );
}
}
+ List stringsInitialized = source.getStringsInitialized();
if ( target.getStringsInitialized() != null ) {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.getStringsInitialized().clear();
target.getStringsInitialized().addAll( list1 );
@@ -203,7 +211,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list1 = source.getStringsInitialized();
+ List list1 = stringsInitialized;
if ( list1 != null ) {
target.setStringsInitialized( new LinkedHashSet<>( list1 ) );
}
@@ -211,8 +219,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setStringsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsInitialized1 = source.getStringsInitialized();
if ( target.getLongsInitialized() != null ) {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.getLongsInitialized().clear();
target.getLongsInitialized().addAll( set1 );
@@ -222,7 +231,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- Set set1 = stringListToLongSet( source.getStringsInitialized() );
+ Set set1 = stringListToLongSet( stringsInitialized1 );
if ( set1 != null ) {
target.setLongsInitialized( set1 );
}
@@ -230,8 +239,9 @@ public Domain updateWithReturn(Dto source, Domain target) {
target.setLongsInitialized( new LinkedHashSet<>() );
}
}
+ List stringsWithDefault = source.getStringsWithDefault();
if ( target.getStringsWithDefault() != null ) {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.getStringsWithDefault().clear();
target.getStringsWithDefault().addAll( list2 );
@@ -241,7 +251,7 @@ public Domain updateWithReturn(Dto source, Domain target) {
}
}
else {
- List list2 = source.getStringsWithDefault();
+ List list2 = stringsWithDefault;
if ( list2 != null ) {
target.setStringsWithDefault( new ArrayList<>( list2 ) );
}
diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java
index 225c002489..de749b5dca 100644
--- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java
+++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithNvmsNullMapperImpl.java
@@ -55,8 +55,9 @@ public void update(Dto source, Domain target) {
return;
}
+ List strings = source.getStrings();
if ( target.getStrings() != null ) {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.getStrings().clear();
target.getStrings().addAll( list );
@@ -66,13 +67,14 @@ public void update(Dto source, Domain target) {
}
}
else {
- List list = source.getStrings();
+ List list = strings;
if ( list != null ) {
target.setStrings( new LinkedHashSet<>( list ) );
}
}
+ List strings1 = source.getStrings();
if ( target.getLongs() != null ) {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.getLongs().clear();
target.getLongs().addAll( set );
@@ -82,13 +84,14 @@ public void update(Dto source, Domain target) {
}
}
else {
- Set set = stringListToLongSet( source.getStrings() );
+ Set set = stringListToLongSet( strings1 );
if ( set != null ) {
target.setLongs( set );
}
}
+ List