From d1388c3a4586e59650c9450e20a4affc71fa041f Mon Sep 17 00:00:00 2001 From: sjaakd Date: Wed, 21 Dec 2016 00:26:21 +0100 Subject: [PATCH] #941 undesired too postfixes in local variable names --- .../mapstruct/ap/internal/model/MappingMethod.java | 12 +++++++----- .../ap/internal/model/source/SourceMethod.java | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/MappingMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/MappingMethod.java index 59416d86e..26024250f 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/MappingMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/MappingMethod.java @@ -90,23 +90,25 @@ public abstract class MappingMethod extends ModelElement { } protected MappingMethod(Method method, List parameters) { - this( method, parameters, method.getParameterNames(), null, null, Collections.emptyList() ); + this( method, parameters, new ArrayList( method.getParameterNames() ), null, null, + Collections.emptyList() ); } protected MappingMethod(Method method) { - this( method, method.getParameterNames(), null, null ); + this( method, new ArrayList( method.getParameterNames() ), null, null ); } protected MappingMethod(Method method, List beforeMappingReferences, List afterMappingReferences) { - this( method, method.getParameterNames(), beforeMappingReferences, afterMappingReferences ); + this( method, new ArrayList( method.getParameterNames() ), beforeMappingReferences, + afterMappingReferences ); } protected MappingMethod(Method method, List beforeMappingReferences, List afterMappingReferences, List forgedMethods) { - this( method, method.getParameters(), method.getParameterNames(), beforeMappingReferences, - afterMappingReferences, forgedMethods ); + this( method, method.getParameters(), new ArrayList( method.getParameterNames() ), + beforeMappingReferences, afterMappingReferences, forgedMethods ); } public MappingMethod(Method method, Collection existingVariableNames, diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/SourceMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/SourceMethod.java index d59df8df3..13becab3f 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/SourceMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/SourceMethod.java @@ -314,11 +314,13 @@ public class SourceMethod implements Method { @Override public List getParameterNames() { if ( parameterNames == null ) { - parameterNames = new ArrayList( parameters.size() ); + List names = new ArrayList( parameters.size() ); for ( Parameter parameter : parameters ) { - parameterNames.add( parameter.getName() ); + names.add( parameter.getName() ); } + + parameterNames = Collections.unmodifiableList( names ); } return parameterNames;