diff --git a/documentation/src/main/asciidoc/chapter-10-advanced-mapping-options.asciidoc b/documentation/src/main/asciidoc/chapter-10-advanced-mapping-options.asciidoc index 4ccad69f2..158aa632f 100644 --- a/documentation/src/main/asciidoc/chapter-10-advanced-mapping-options.asciidoc +++ b/documentation/src/main/asciidoc/chapter-10-advanced-mapping-options.asciidoc @@ -180,7 +180,7 @@ By default the target property will be set to null. However: 1. By specifying `nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.SET_TO_DEFAULT` on `@Mapping`, `@BeanMapping`, `@Mapper` or `@MapperConfig`, the mapping result can be altered to return *default* values. -For `List` MapStruct generates an `ArrayList`, for `Map` a `HashMap`, for arrays an empty array, for `String` `""` and for primitive / boxed types a representation of `false` or `0`. +For `List` MapStruct generates an `ArrayList`, for `Map` a `LinkedHashMap`, for arrays an empty array, for `String` `""` and for primitive / boxed types a representation of `false` or `0`. For all other objects an new instance is created. Please note that a default constructor is required. If not available, use the `@Mapping#defaultValue`. 2. By specifying `nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE` on `@Mapping`, `@BeanMapping`, `@Mapper` or `@MapperConfig`, the mapping result will be equal to the original value of the `@MappingTarget` annotated target. diff --git a/documentation/src/main/asciidoc/chapter-6-mapping-collections.asciidoc b/documentation/src/main/asciidoc/chapter-6-mapping-collections.asciidoc index 785b460b1..17025da4d 100644 --- a/documentation/src/main/asciidoc/chapter-6-mapping-collections.asciidoc +++ b/documentation/src/main/asciidoc/chapter-6-mapping-collections.asciidoc @@ -36,7 +36,7 @@ public Set integerSetToStringSet(Set integers) { return null; } - Set set = new HashSet(); + Set set = new LinkedHashSet(); for ( Integer integer : integers ) { set.add( String.valueOf( integer ) ); @@ -125,7 +125,7 @@ public Map stringStringMapToLongDateMap(Map source) return null; } - Map map = new HashMap(); + Map map = new LinkedHashMap(); for ( Map.Entry entry : source.entrySet() ) { @@ -210,13 +210,13 @@ When an iterable or map mapping method declares an interface type as return type |`List`|`ArrayList` -|`Set`|`HashSet` +|`Set`|`LinkedHashSet` |`SortedSet`|`TreeSet` |`NavigableSet`|`TreeSet` -|`Map`|`HashMap` +|`Map`|`LinkedHashMap` |`SortedMap`|`TreeMap` diff --git a/documentation/src/main/asciidoc/chapter-7-mapping-streams.asciidoc b/documentation/src/main/asciidoc/chapter-7-mapping-streams.asciidoc index ccc3e5685..ec41719eb 100644 --- a/documentation/src/main/asciidoc/chapter-7-mapping-streams.asciidoc +++ b/documentation/src/main/asciidoc/chapter-7-mapping-streams.asciidoc @@ -42,7 +42,7 @@ public Set integerStreamToStringSet(Stream integers) { } return integers.map( integer -> String.valueOf( integer ) ) - .collect( Collectors.toCollection( HashSet::new ) ); + .collect( Collectors.toCollection( LinkedHashSet::new ) ); } @Override diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java index f8c67f740..127ec7427 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java @@ -10,6 +10,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.NavigableMap; @@ -116,11 +118,11 @@ public class TypeFactory { implementationTypes.put( Collection.class.getName(), withInitialCapacity( getType( ArrayList.class ) ) ); implementationTypes.put( List.class.getName(), withInitialCapacity( getType( ArrayList.class ) ) ); - implementationTypes.put( Set.class.getName(), withLoadFactorAdjustment( getType( HashSet.class ) ) ); + implementationTypes.put( Set.class.getName(), withLoadFactorAdjustment( getType( LinkedHashSet.class ) ) ); implementationTypes.put( SortedSet.class.getName(), withDefaultConstructor( getType( TreeSet.class ) ) ); implementationTypes.put( NavigableSet.class.getName(), withDefaultConstructor( getType( TreeSet.class ) ) ); - implementationTypes.put( Map.class.getName(), withLoadFactorAdjustment( getType( HashMap.class ) ) ); + implementationTypes.put( Map.class.getName(), withLoadFactorAdjustment( getType( LinkedHashMap.class ) ) ); implementationTypes.put( SortedMap.class.getName(), withDefaultConstructor( getType( TreeMap.class ) ) ); implementationTypes.put( NavigableMap.class.getName(), withDefaultConstructor( getType( TreeMap.class ) ) ); implementationTypes.put( diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1453/Issue1453MapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1453/Issue1453MapperImpl.java index 00e01f6f1..201b00760 100644 --- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1453/Issue1453MapperImpl.java +++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1453/Issue1453MapperImpl.java @@ -6,7 +6,7 @@ package org.mapstruct.ap.test.bugs._1453; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.annotation.Generated; @@ -68,7 +68,7 @@ public class Issue1453MapperImpl implements Issue1453Mapper { return null; } - Map map = new HashMap( Math.max( (int) ( auctions.size() / .75f ) + 1, 16 ) ); + Map map = new LinkedHashMap( Math.max( (int) ( auctions.size() / .75f ) + 1, 16 ) ); for ( java.util.Map.Entry entry : auctions.entrySet() ) { AuctionDto key = map( entry.getKey() ); @@ -85,7 +85,7 @@ public class Issue1453MapperImpl implements Issue1453Mapper { return null; } - Map map = new HashMap( Math.max( (int) ( auctions.size() / .75f ) + 1, 16 ) ); + Map map = new LinkedHashMap( Math.max( (int) ( auctions.size() / .75f ) + 1, 16 ) ); for ( java.util.Map.Entry entry : auctions.entrySet() ) { AuctionDto key = map( entry.getKey() ); @@ -126,7 +126,7 @@ public class Issue1453MapperImpl implements Issue1453Mapper { return null; } - Map map1 = new HashMap( Math.max( (int) ( map.size() / .75f ) + 1, 16 ) ); + Map map1 = new LinkedHashMap( Math.max( (int) ( map.size() / .75f ) + 1, 16 ) ); for ( java.util.Map.Entry entry : map.entrySet() ) { PaymentDto key = paymentToPaymentDto( entry.getKey() ); diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1707/ConverterImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1707/ConverterImpl.java index 898b13418..abe4a62a3 100644 --- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1707/ConverterImpl.java +++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_1707/ConverterImpl.java @@ -5,7 +5,7 @@ */ package org.mapstruct.ap.test.bugs._1707; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -24,10 +24,10 @@ public class ConverterImpl extends Converter { return null; } - Set set = new HashSet(); + Set set = new LinkedHashSet(); set.addAll( source.map( source1 -> convert( source1 ) ) - .collect( Collectors.toCollection( HashSet::new ) ) + .collect( Collectors.toCollection( LinkedHashSet::new ) ) ); addCustomValue( set ); 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 e7e1be5b1..b3a8c89c6 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 @@ -6,7 +6,7 @@ package org.mapstruct.ap.test.bugs._913; import java.util.ArrayList; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.annotation.Generated; @@ -30,14 +30,14 @@ public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlway if ( source.hasStrings() ) { List list = source.getStrings(); - domain.setStrings( new HashSet( list ) ); + domain.setStrings( new LinkedHashSet( list ) ); } if ( source.hasStrings() ) { domain.setLongs( stringListToLongSet( source.getStrings() ) ); } if ( source.hasStringsInitialized() ) { List list1 = source.getStringsInitialized(); - domain.setStringsInitialized( new HashSet( list1 ) ); + domain.setStringsInitialized( new LinkedHashSet( list1 ) ); } if ( source.hasStringsInitialized() ) { domain.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) ); @@ -68,7 +68,7 @@ public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlway else { if ( source.hasStrings() ) { List list = source.getStrings(); - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -91,7 +91,7 @@ public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlway else { if ( source.hasStringsInitialized() ) { List list1 = source.getStringsInitialized(); - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -140,7 +140,7 @@ public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlway else { if ( source.hasStrings() ) { List list = source.getStrings(); - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -163,7 +163,7 @@ public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlway else { if ( source.hasStringsInitialized() ) { List list1 = source.getStringsInitialized(); - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -204,7 +204,7 @@ public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlway return null; } - Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); + Set set = new LinkedHashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); for ( String string : list ) { set.add( Long.parseLong( string ) ); } 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 f0f2ea5f0..f1bf0fa78 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 @@ -6,7 +6,7 @@ package org.mapstruct.ap.test.bugs._913; import java.util.ArrayList; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.annotation.Generated; @@ -28,12 +28,12 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa if ( source != null ) { List list = source.getStrings(); if ( list != null ) { - domain.setStrings( new HashSet( list ) ); + domain.setStrings( new LinkedHashSet( list ) ); } domain.setLongs( stringListToLongSet( source.getStrings() ) ); List list1 = source.getStringsInitialized(); if ( list1 != null ) { - domain.setStringsInitialized( new HashSet( list1 ) ); + domain.setStringsInitialized( new LinkedHashSet( list1 ) ); } domain.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) ); List list2 = source.getStringsWithDefault(); @@ -59,13 +59,13 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getStrings().addAll( list ); } else { - target.setStrings( new HashSet() ); + target.setStrings( new LinkedHashSet() ); } } else { List list = source.getStrings(); if ( list != null ) { - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -75,7 +75,7 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getLongs().addAll( set ); } else { - target.setLongs( new HashSet() ); + target.setLongs( new LinkedHashSet() ); } } else { @@ -91,13 +91,13 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getStringsInitialized().addAll( list1 ); } else { - target.setStringsInitialized( new HashSet() ); + target.setStringsInitialized( new LinkedHashSet() ); } } else { List list1 = source.getStringsInitialized(); if ( list1 != null ) { - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -107,7 +107,7 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getLongsInitialized().addAll( set1 ); } else { - target.setLongsInitialized( new HashSet() ); + target.setLongsInitialized( new LinkedHashSet() ); } } else { @@ -149,13 +149,13 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getStrings().addAll( list ); } else { - target.setStrings( new HashSet() ); + target.setStrings( new LinkedHashSet() ); } } else { List list = source.getStrings(); if ( list != null ) { - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -165,7 +165,7 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getLongs().addAll( set ); } else { - target.setLongs( new HashSet() ); + target.setLongs( new LinkedHashSet() ); } } else { @@ -181,13 +181,13 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getStringsInitialized().addAll( list1 ); } else { - target.setStringsInitialized( new HashSet() ); + target.setStringsInitialized( new LinkedHashSet() ); } } else { List list1 = source.getStringsInitialized(); if ( list1 != null ) { - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -197,7 +197,7 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa target.getLongsInitialized().addAll( set1 ); } else { - target.setLongsInitialized( new HashSet() ); + target.setLongsInitialized( new LinkedHashSet() ); } } else { @@ -232,10 +232,10 @@ public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefa protected Set stringListToLongSet(List list) { if ( list == null ) { - return new HashSet(); + return new LinkedHashSet(); } - Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); + Set set = new LinkedHashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); for ( String string : list ) { set.add( Long.parseLong( string ) ); } 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 a07601a4d..59a770d04 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 @@ -6,7 +6,7 @@ package org.mapstruct.ap.test.bugs._913; import java.util.ArrayList; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.annotation.Generated; @@ -30,12 +30,12 @@ public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMap List list = source.getStrings(); if ( list != null ) { - domain.setStrings( new HashSet( list ) ); + domain.setStrings( new LinkedHashSet( list ) ); } domain.setLongs( stringListToLongSet( source.getStrings() ) ); List list1 = source.getStringsInitialized(); if ( list1 != null ) { - domain.setStringsInitialized( new HashSet( list1 ) ); + domain.setStringsInitialized( new LinkedHashSet( list1 ) ); } domain.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) ); List list2 = source.getStringsWithDefault(); @@ -68,7 +68,7 @@ public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMap else { List list = source.getStrings(); if ( list != null ) { - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -100,7 +100,7 @@ public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMap else { List list1 = source.getStringsInitialized(); if ( list1 != null ) { - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -159,7 +159,7 @@ public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMap else { List list = source.getStrings(); if ( list != null ) { - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -191,7 +191,7 @@ public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMap else { List list1 = source.getStringsInitialized(); if ( list1 != null ) { - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -238,7 +238,7 @@ public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMap return null; } - Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); + Set set = new LinkedHashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); for ( String string : list ) { set.add( Long.parseLong( string ) ); } diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java index 6ed369c4d..ba18dfda1 100644 --- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java +++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/bugs/_913/DomainDtoWithPresenceCheckMapperImpl.java @@ -6,7 +6,7 @@ package org.mapstruct.ap.test.bugs._913; import java.util.ArrayList; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.annotation.Generated; @@ -30,12 +30,12 @@ public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresen if ( source.hasStrings() ) { List list = source.getStrings(); - domain.setStrings( new HashSet( list ) ); + domain.setStrings( new LinkedHashSet( list ) ); } domain.setLongs( stringListToLongSet( source.getStrings() ) ); if ( source.hasStringsInitialized() ) { List list1 = source.getStringsInitialized(); - domain.setStringsInitialized( new HashSet( list1 ) ); + domain.setStringsInitialized( new LinkedHashSet( list1 ) ); } domain.setLongsInitialized( stringListToLongSet( source.getStringsInitialized() ) ); if ( source.hasStringsWithDefault() ) { @@ -64,7 +64,7 @@ public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresen else { if ( source.hasStrings() ) { List list = source.getStrings(); - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -87,7 +87,7 @@ public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresen else { if ( source.hasStringsInitialized() ) { List list1 = source.getStringsInitialized(); - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -136,7 +136,7 @@ public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresen else { if ( source.hasStrings() ) { List list = source.getStrings(); - target.setStrings( new HashSet( list ) ); + target.setStrings( new LinkedHashSet( list ) ); } } if ( target.getLongs() != null ) { @@ -159,7 +159,7 @@ public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresen else { if ( source.hasStringsInitialized() ) { List list1 = source.getStringsInitialized(); - target.setStringsInitialized( new HashSet( list1 ) ); + target.setStringsInitialized( new LinkedHashSet( list1 ) ); } } if ( target.getLongsInitialized() != null ) { @@ -200,7 +200,7 @@ public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresen return null; } - Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); + Set set = new LinkedHashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) ); for ( String string : list ) { set.add( Long.parseLong( string ) ); } diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/collection/defaultimplementation/SourceTargetMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/collection/defaultimplementation/SourceTargetMapperImpl.java index 631002617..853ad5956 100644 --- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/collection/defaultimplementation/SourceTargetMapperImpl.java +++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/collection/defaultimplementation/SourceTargetMapperImpl.java @@ -7,8 +7,8 @@ package org.mapstruct.ap.test.collection.defaultimplementation; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.NavigableMap; @@ -82,7 +82,7 @@ public class SourceTargetMapperImpl implements SourceTargetMapper { return null; } - Set set = new HashSet( Math.max( (int) ( foos.size() / .75f ) + 1, 16 ) ); + Set set = new LinkedHashSet( Math.max( (int) ( foos.size() / .75f ) + 1, 16 ) ); for ( SourceFoo sourceFoo : foos ) { set.add( sourceFooToTargetFoo( sourceFoo ) ); } @@ -178,7 +178,7 @@ public class SourceTargetMapperImpl implements SourceTargetMapper { return null; } - Map map = new HashMap( Math.max( (int) ( foos.size() / .75f ) + 1, 16 ) ); + Map map = new LinkedHashMap( Math.max( (int) ( foos.size() / .75f ) + 1, 16 ) ); for ( java.util.Map.Entry entry : foos.entrySet() ) { String key = String.valueOf( entry.getKey() ); diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java index 121dbea3e..5eff50e34 100644 --- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java +++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/CompanyMapper1Impl.java @@ -5,7 +5,7 @@ */ package org.mapstruct.ap.test.updatemethods; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; @@ -83,7 +83,7 @@ public class CompanyMapper1Impl implements CompanyMapper1 { return null; } - Map map1 = new HashMap( Math.max( (int) ( map.size() / .75f ) + 1, 16 ) ); + Map map1 = new LinkedHashMap( Math.max( (int) ( map.size() / .75f ) + 1, 16 ) ); for ( java.util.Map.Entry entry : map.entrySet() ) { SecretaryEntity key = secretaryDtoToSecretaryEntity( entry.getKey() ); diff --git a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/selection/DepartmentMapperImpl.java b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/selection/DepartmentMapperImpl.java index 338d6e9b5..1f21f0f63 100644 --- a/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/selection/DepartmentMapperImpl.java +++ b/processor/src/test/resources/fixtures/org/mapstruct/ap/test/updatemethods/selection/DepartmentMapperImpl.java @@ -6,7 +6,7 @@ package org.mapstruct.ap.test.updatemethods.selection; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; import javax.annotation.Generated; import org.mapstruct.ap.test.updatemethods.DepartmentDto; import org.mapstruct.ap.test.updatemethods.DepartmentEntity; @@ -42,7 +42,7 @@ public class DepartmentMapperImpl implements DepartmentMapper { } if ( dto.getSecretaryToEmployee() != null ) { if ( entity.getSecretaryToEmployee() == null ) { - entity.setSecretaryToEmployee( new HashMap() ); + entity.setSecretaryToEmployee( new LinkedHashMap() ); } externalHandWrittenMapper.toSecretaryEmployeeEntityMap( dto.getSecretaryToEmployee(), entity.getSecretaryToEmployee() ); }