diff --git a/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Bar.java b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Bar.java new file mode 100644 index 000000000..71caf1758 --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Bar.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +public class Bar { + private final String id; + + public Bar(String id) { + this.id = id; + } + + public String getId() { + return id; + } +} diff --git a/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Foo.java b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Foo.java new file mode 100644 index 000000000..8628bbbf7 --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Foo.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +public class Foo { + private final long id; + + public Foo(long id) { + this.id = id; + } + + public long getId() { + return id; + } +} diff --git a/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/MyMapper.java b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/MyMapper.java new file mode 100644 index 000000000..bb84bdfcd --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/MyMapper.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public class MyMapper { + public BigDecimal mapBigIntToDecimal(BigInteger source) { + return source == null ? null : new BigDecimal( source ); + } +} diff --git a/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Source.java b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Source.java new file mode 100644 index 000000000..5637a2134 --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Source.java @@ -0,0 +1,45 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +import java.math.BigInteger; + +public class Source { + private final long idFoo; + private final String idBar; + private final BigInteger number; + + public Source(long idFoo, String idBar, BigInteger number) { + this.idFoo = idFoo; + this.idBar = idBar; + this.number = number; + } + + public long getIdFoo() { + return idFoo; + } + + public String getIdBar() { + return idBar; + } + + public BigInteger getNumber() { + return number; + } +} diff --git a/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/SourceTargetMapper.java b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/SourceTargetMapper.java new file mode 100644 index 000000000..7b12f025b --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/SourceTargetMapper.java @@ -0,0 +1,44 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper(uses = MyMapper.class) +public interface SourceTargetMapper { + SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); + + @Mappings({ + @Mapping(source = "idFoo", target = "foo"), + @Mapping(source = "idBar", target = "bar"), + @Mapping(source = "number", target = "number") + }) + Target mapSourceToTarget(Source source); + + default Foo fooFromId(long id) { + return new Foo(id); + } + + static Bar barFromId(String id) { + return new Bar(id); + } +} diff --git a/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Target.java b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Target.java new file mode 100644 index 000000000..95a6c0718 --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/main/java/org/mapstruct/ap/test/bugs/_636/Target.java @@ -0,0 +1,51 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +import java.math.BigDecimal; + +public class Target { + private Foo foo; + private Bar bar; + private BigDecimal number; + + public Foo getFoo() { + return foo; + } + + public void setFoo(Foo foo) { + this.foo = foo; + } + + public Bar getBar() { + return bar; + } + + public void setBar(Bar bar) { + this.bar = bar; + } + + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } +} diff --git a/integrationtest/src/test/resources/java8Test/src/test/java/org/mapstruct/ap/test/bugs/_636/Issue636Test.java b/integrationtest/src/test/resources/java8Test/src/test/java/org/mapstruct/ap/test/bugs/_636/Issue636Test.java new file mode 100644 index 000000000..82ed75336 --- /dev/null +++ b/integrationtest/src/test/resources/java8Test/src/test/java/org/mapstruct/ap/test/bugs/_636/Issue636Test.java @@ -0,0 +1,48 @@ +/** + * Copyright 2012-2015 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._636; + +import java.math.BigInteger; + +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +public class Issue636Test { + + @Test + public void shouldMapDataFromJava8Interface() { + + final long idFoo = 123; + final String idBar = "Bar456"; + final BigInteger number = BigInteger.valueOf( 789L ); + + final Source source = new Source( idFoo, idBar, number ); + + final Target target = SourceTargetMapper.INSTANCE.mapSourceToTarget( source ); + + assertThat( target ).isNotNull(); + assertThat( target.getFoo() ).isNotNull(); + assertThat( target.getFoo().getId() ).isEqualTo( idFoo ); + assertThat( target.getBar() ).isNotNull(); + assertThat( target.getBar().getId() ).isEqualTo( idBar ); + assertThat( target.getNumber() ).isNotNull(); + assertThat( target.getNumber().toBigInteger() ).isEqualTo( number ); + } +} 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 4f9705b46..a01bb5144 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 @@ -47,6 +47,7 @@ public abstract class MappingMethod extends ModelElement { private final Accessibility accessibility; private final List thrownTypes; private final boolean isStatic; + private final Type staticMethodFromInterfaceType; private final String resultName; private final List beforeMappingReferencesWithMappingTarget; private final List beforeMappingReferencesWithoutMappingTarget; @@ -69,6 +70,7 @@ public abstract class MappingMethod extends ModelElement { this.accessibility = method.getAccessibility(); this.thrownTypes = method.getThrownTypes(); this.isStatic = method.isStatic(); + this.staticMethodFromInterfaceType = method.getStaticMethodFromInterfaceType(); this.resultName = initResultName( existingVariableNames ); this.beforeMappingReferencesWithMappingTarget = filterMappingTarget( beforeMappingReferences, true ); this.beforeMappingReferencesWithoutMappingTarget = filterMappingTarget( beforeMappingReferences, false ); @@ -144,6 +146,10 @@ public abstract class MappingMethod extends ModelElement { return isStatic; } + public Type getStaticMethodFromInterfaceType() { + return staticMethodFromInterfaceType; + } + @Override public Set getImportTypes() { Set types = new HashSet(); @@ -154,6 +160,9 @@ public abstract class MappingMethod extends ModelElement { types.add( getReturnType() ); types.addAll( thrownTypes ); + if ( staticMethodFromInterfaceType != null ) { + types.add( staticMethodFromInterfaceType ); + } return types; } diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethod.java index 1d20f7cc5..e0c00c62e 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethod.java @@ -192,6 +192,16 @@ public class ForgedMethod implements Method { return false; } + @Override + public boolean isDefault() { + return false; + } + + @Override + public Type getStaticMethodFromInterfaceType() { + return null; + } + @Override public MapperConfiguration getMapperConfiguration() { return null; diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/Method.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/Method.java index 9e39b923c..d3fc47f1a 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/Method.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/Method.java @@ -144,6 +144,20 @@ public interface Method { */ boolean isStatic(); + /** + * Whether this method is Java 8 default method + * + * @return true when Java 8 default method + */ + boolean isDefault(); + + /** + * Returns method's enclosing type if method is Java 8 static method + * + * @return type of static method from Java 8 interface + */ + Type getStaticMethodFromInterfaceType(); + /** * * @return the mapper config when this method needs to be implemented 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 3484a07cc..298236ac5 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 @@ -66,6 +66,8 @@ public class SourceMethod implements Method { private final MapperConfiguration config; private final MappingOptions mappingOptions; private final List prototypeMethods; + private final boolean defaultMethod; + private final Type staticMethodFromInterfaceType; private List sourceParameters; @@ -89,6 +91,8 @@ public class SourceMethod implements Method { private FormattingMessager messager = null; private MapperConfiguration mapperConfig = null; private List prototypeMethods = Collections.emptyList(); + private boolean defaultMethod; + private Type staticMethodFromInterfaceType; public Builder() { } @@ -163,6 +167,16 @@ public class SourceMethod implements Method { return this; } + public Builder setDefaultMethod(boolean defaultMethod) { + this.defaultMethod = defaultMethod; + return this; + } + + public Builder setStaticMethodFromInterfaceType(Type staticMethodFromInterfaceType) { + this.staticMethodFromInterfaceType = staticMethodFromInterfaceType; + return this; + } + public SourceMethod build() { MappingOptions mappingOptions @@ -178,7 +192,9 @@ public class SourceMethod implements Method { typeUtils, typeFactory, mapperConfig, - prototypeMethods + prototypeMethods, + defaultMethod, + staticMethodFromInterfaceType ); if ( mappings != null ) { @@ -194,8 +210,9 @@ public class SourceMethod implements Method { @SuppressWarnings("checkstyle:parameternumber") private SourceMethod(Type declaringMapper, ExecutableElement executable, List parameters, - Type returnType, List exceptionTypes, MappingOptions mappingOptions, Types typeUtils, - TypeFactory typeFactory, MapperConfiguration config, List prototypeMethods) { + Type returnType, List exceptionTypes, MappingOptions mappingOptions, Types typeUtils, + TypeFactory typeFactory, MapperConfiguration config, List prototypeMethods, + boolean defaultMethod, Type staticMethodFromInterfaceType) { this.declaringMapper = declaringMapper; this.executable = executable; this.parameters = parameters; @@ -212,6 +229,8 @@ public class SourceMethod implements Method { this.typeFactory = typeFactory; this.config = config; this.prototypeMethods = prototypeMethods; + this.defaultMethod = defaultMethod; + this.staticMethodFromInterfaceType = staticMethodFromInterfaceType; } private Parameter determineMappingTargetParameter(Iterable parameters) { @@ -511,6 +530,15 @@ public class SourceMethod implements Method { return executable.getModifiers().contains( Modifier.STATIC ); } + @Override + public boolean isDefault() { + return defaultMethod; + } + + @Override + public Type getStaticMethodFromInterfaceType() { + return staticMethodFromInterfaceType; + } @Override public MapperConfiguration getMapperConfiguration() { diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMethod.java index 8eb2a7d41..c11d28450 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMethod.java @@ -239,6 +239,16 @@ public abstract class BuiltInMethod implements Method { return false; } + @Override + public boolean isDefault() { + return false; + } + + @Override + public Type getStaticMethodFromInterfaceType() { + return null; + } + @Override public MapperConfiguration getMapperConfiguration() { return null; diff --git a/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperCreationProcessor.java b/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperCreationProcessor.java index 198a26fd1..7baf98730 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperCreationProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperCreationProcessor.java @@ -187,7 +187,7 @@ public class MapperCreationProcessor implements ModelElementProcessor prototypeMethods = - retrievePrototypeMethods( mapperConfig.getMapperConfigMirror(), mapperConfig ); + retrievePrototypeMethods( mapperConfig.getMapperConfigMirror(), mapperConfig, mapperTypeElement ); return retrieveMethods( mapperTypeElement, mapperTypeElement, mapperConfig, prototypeMethods ); } @@ -96,7 +96,8 @@ public class MethodRetrievalProcessor implements ModelElementProcessor retrievePrototypeMethods(TypeMirror typeMirror, MapperConfiguration mapperConfig) { + private List retrievePrototypeMethods(TypeMirror typeMirror, MapperConfiguration mapperConfig, + TypeElement mapperTypeElement) { if ( typeMirror == null || typeMirror.getKind() == TypeKind.VOID ) { return Collections.emptyList(); } @@ -119,7 +120,9 @@ public class MethodRetrievalProcessor implements ModelElementProcessor parameters, boolean containsTargetTypeParameter, MapperConfiguration mapperConfig, - List prototypeMethods) { + List prototypeMethods, + TypeElement mapperToImplement) { Type returnType = typeFactory.getReturnType( methodType ); List exceptionTypes = typeFactory.getThrownTypes( methodType ); List sourceParameters = extractSourceParameters( parameters ); @@ -234,19 +239,25 @@ public class MethodRetrievalProcessor implements ModelElementProcessor exceptionTypes = typeFactory.getThrownTypes( methodType ); Type usedMapperAsType = typeFactory.getType( usedMapper ); Type mapperToImplementAsType = typeFactory.getType( mapperToImplement ); + Type staticMethodFromInterfaceType = findStaticMethodFromInterfaceType( method ); if ( !mapperToImplementAsType.canAccess( usedMapperAsType, method ) ) { return null; } return new SourceMethod.Builder() - .setDeclaringMapper( usedMapper.equals( mapperToImplement ) ? null : usedMapperAsType ) - .setExecutable( method ) - .setParameters( parameters ) - .setReturnType( returnType ) - .setExceptionTypes( exceptionTypes ) - .setTypeUtils( typeUtils ) - .setTypeFactory( typeFactory ) - .build(); + .setDeclaringMapper( usedMapper.equals( mapperToImplement ) ? null : usedMapperAsType ) + .setExecutable( method ) + .setParameters( parameters ) + .setReturnType( returnType ) + .setExceptionTypes( exceptionTypes ) + .setTypeUtils( typeUtils ) + .setTypeFactory( typeFactory ) + .setDefaultMethod( Executables.isInterfaceDefaultMethod( method, mapperToImplement ) ) + .setStaticMethodFromInterfaceType( staticMethodFromInterfaceType ) + .build(); + } + + private Type findStaticMethodFromInterfaceType(ExecutableElement method) { + Element enclosingElement = method.getEnclosingElement(); + boolean staticMethodFromInterface = ( enclosingElement.getKind().isInterface() && + Executables.isStaticFromInterfaceMethod( + method, ( (TypeElement) enclosingElement ) + ) + ); + return staticMethodFromInterface ? typeFactory.getType( enclosingElement.asType() ) : null; } private boolean isValidLifecycleCallbackMethod(ExecutableElement method, Type returnType) { diff --git a/processor/src/main/java/org/mapstruct/ap/internal/util/Executables.java b/processor/src/main/java/org/mapstruct/ap/internal/util/Executables.java index 3794ce9ed..be3ed1068 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/util/Executables.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/util/Executables.java @@ -187,9 +187,7 @@ public class Executables { List methodsToAdd, TypeElement parentType) { List safeToAdd = new ArrayList( methodsToAdd.size() ); for ( ExecutableElement toAdd : methodsToAdd ) { - if ( isNotStaticMethodInInterface( toAdd, parentType ) - && isNotInterfaceDefaultMethod( toAdd, parentType ) - && isNotObjectEquals( toAdd ) + if ( isNotObjectEquals( toAdd ) && wasNotYetOverridden( elementUtils, alreadyCollected, toAdd, parentType ) ) { safeToAdd.add( toAdd ); } @@ -198,16 +196,16 @@ public class Executables { alreadyCollected.addAll( 0, safeToAdd ); } - private static boolean isNotStaticMethodInInterface(ExecutableElement element, TypeElement parentType) { - return !( parentType.getKind().isInterface() && + public static boolean isInterfaceDefaultMethod(ExecutableElement element, TypeElement parentType) { + return parentType.getKind().isInterface() && element.getKind() == ElementKind.METHOD && - element.getModifiers().containsAll( Arrays.asList( Modifier.PUBLIC, Modifier.STATIC ) ) ); + isDefaultMethod( element ); } - private static boolean isNotInterfaceDefaultMethod(ExecutableElement element, TypeElement parentType) { - return !( parentType.getKind().isInterface() && + public static boolean isStaticFromInterfaceMethod(ExecutableElement element, TypeElement parentType) { + return parentType.getKind().isInterface() && element.getKind() == ElementKind.METHOD && - isDefaultMethod( element ) ); + element.getModifiers().containsAll( Arrays.asList( Modifier.PUBLIC, Modifier.STATIC ) ); } /** diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/MethodReference.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/MethodReference.ftl index 6e4ae9adf..82505b852 100644 --- a/processor/src/main/resources/org/mapstruct/ap/internal/model/MethodReference.ftl +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/MethodReference.ftl @@ -20,7 +20,16 @@ --> <@compress single_line=true> <#-- method is either internal to the mapper class, or external (via uses) declaringMapper!=null --> - <#if declaringMapper??><#if static><@includeModel object=declaringMapper.type/><#else>${mapperVariableName}.${name}<#if (parameters?size > 0)>( <@arguments/> )<#else>() + <#if declaringMapper??><#if static><@includeModel object=declaringMapper.type/><#else>${mapperVariableName}.<@params/> + <#elseif staticMethodFromInterfaceType??><@includeModel object=staticMethodFromInterfaceType/>.<@params/> + <#else> + <@params/> + + <#macro params> + <@compress> + ${name}<#if (parameters?size > 0)>( <@arguments/> )<#else>() + + <#macro arguments> <#list parameters as param> <#if param.targetType>