Skip to content

Commit e34abec

Browse files
committed
Polish
1 parent bf29109 commit e34abec

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

processor/src/main/java/org/mapstruct/ap/internal/model/ContainerMappingMethod.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public abstract class ContainerMappingMethod extends NormalTypeMappingMethod {
4747
this.elementAssignment = parameterAssignment;
4848
this.loopVariableName = loopVariableName;
4949
this.selectionParameters = selectionParameters != null ? selectionParameters : SelectionParameters.empty();
50+
5051
this.index1Name = Strings.getSafeVariableName( "i", existingVariables );
5152
this.index2Name = Strings.getSafeVariableName( "j", existingVariables );
5253

processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ public Type getImplementationType() {
317317
return implementationType != null ? implementationType.getType() : null;
318318
}
319319

320-
public String getFactoryMethodName() {
321-
return implementationType != null ? implementationType.getFactoryMethodName() : null;
322-
}
323-
324320
public ImplementationType getImplementation() {
325321
return implementationType;
326322
}

processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public class TypeFactory {
9191
private final TypeUtils typeUtils;
9292
private final FormattingMessager messager;
9393
private final RoundContext roundContext;
94-
private final VersionInformation versionInformation;
9594

9695
private final TypeMirror iterableType;
9796
private final TypeMirror collectionType;
@@ -111,7 +110,6 @@ public TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMes
111110
this.typeUtils = typeUtils;
112111
this.messager = messager;
113112
this.roundContext = roundContext;
114-
this.versionInformation = versionInformation;
115113
this.notToBeImportedTypes = notToBeImportedTypes;
116114

117115
iterableType = typeUtils.erasure( elementUtils.getTypeElement( Iterable.class.getCanonicalName() ).asType() );
@@ -125,9 +123,10 @@ public TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMes
125123
implementationTypes.put( Collection.class.getName(), withInitialCapacity( getType( ArrayList.class ) ) );
126124
implementationTypes.put( List.class.getName(), withInitialCapacity( getType( ArrayList.class ) ) );
127125

126+
boolean sourceVersionAtLeast19 = versionInformation.isSourceVersionAtLeast19();
128127
implementationTypes.put(
129128
Set.class.getName(),
130-
isSourceVersionAtLeast19() ?
129+
sourceVersionAtLeast19 ?
131130
withFactoryMethod( getType( LinkedHashSet.class ), LINKED_HASH_SET_FACTORY_METHOD_NAME ) :
132131
withLoadFactorAdjustment( getType( LinkedHashSet.class ) )
133132
);
@@ -136,7 +135,7 @@ public TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMes
136135

137136
implementationTypes.put(
138137
Map.class.getName(),
139-
isSourceVersionAtLeast19() ?
138+
sourceVersionAtLeast19 ?
140139
withFactoryMethod( getType( LinkedHashMap.class ), LINKED_HASH_MAP_FACTORY_METHOD_NAME ) :
141140
withLoadFactorAdjustment( getType( LinkedHashMap.class ) )
142141
);
@@ -480,10 +479,6 @@ private boolean isExecutableType(TypeMirror accessorType) {
480479
return accessorType.getKind() == TypeKind.EXECUTABLE;
481480
}
482481

483-
private boolean isSourceVersionAtLeast19() {
484-
return versionInformation != null && versionInformation.isSourceVersionAtLeast19();
485-
}
486-
487482
public Type getReturnType(ExecutableType method) {
488483
return getType( method.getReturnType() );
489484
}

processor/src/main/resources/org/mapstruct/ap/internal/model/IterableCreation.ftl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
<@includeModel object=factoryMethod targetType=resultType/>
1212
<#elseif enumSet>
1313
EnumSet.noneOf( <@includeModel object=enumSetElementType raw=true/>.class )
14-
<#elseif resultType.implementationType?? && resultType.factoryMethodName?? && ext.useSizeIfPossible?? && ext.useSizeIfPossible && canUseSize>
15-
<@includeModel object=resultType.implementationType raw=true />.${resultType.factoryMethodName}( <@iterableSize /> )
16-
<#else>
17-
new
18-
<#if resultType.implementationType??>
19-
<@includeModel object=resultType.implementationType/><#if ext.useSizeIfPossible?? && ext.useSizeIfPossible && canUseSize>( <@sizeForCreation /> )<#else>()</#if>
14+
<#elseif resultType.implementation??>
15+
<#if resultType.implementation.factoryMethodName?? && ext.useSizeIfPossible?? && ext.useSizeIfPossible && canUseSize>
16+
<@includeModel object=resultType.implementationType raw=true />.${resultType.implementation.factoryMethodName}( <@sizeForCreation /> )
2017
<#else>
21-
<@includeModel object=resultType/>()</#if>
18+
new <@includeModel object=resultType.implementationType/><#if ext.useSizeIfPossible?? && ext.useSizeIfPossible && canUseSize>( <@sizeForCreation /> )<#else>()</#if>
2219
</#if>
20+
<#else>
21+
new <@includeModel object=resultType/>()
22+
</#if>
2323
</@compress>
2424
<#macro sizeForCreation>
2525
<@compress single_line=true>

0 commit comments

Comments
 (0)