diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl index c843b2d63..0103202b3 100644 --- a/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl @@ -1,3 +1,4 @@ +<#-- @ftlvariable name="" type="org.mapstruct.ap.internal.model.common.Type" --> <#-- Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) @@ -18,4 +19,19 @@ limitations under the License. --> -<#if imported>${name}<#else>${fullyQualifiedName}<#if (!ext.raw?? && typeParameters?size > 0) ><<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, > \ No newline at end of file +<@compress single_line=true> + <#if wildCardExtendsBound> + ? extends <@includeModel object=typeBound /> + <#elseif wildCardSuperBound> + ? super <@includeModel object=typeBound /> + <#else> + <#if imported> + ${name} + <#else> + ${fullyQualifiedName} + + + <#if (!ext.raw?? && typeParameters?size > 0) > + <<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, > + + \ No newline at end of file diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java index c8460b63d..2b48533ef 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java @@ -25,6 +25,7 @@ import java.math.BigDecimal; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mapstruct.ap.testutil.IssueKey; @@ -33,6 +34,7 @@ import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; +import org.mapstruct.ap.testutil.runner.GeneratedSource; /** * Reproducer for https://github.com/mapstruct/mapstruct/issues/527. @@ -43,6 +45,9 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; @RunWith(AnnotationProcessorTestRunner.class) public class WildCardTest { + @Rule + public final GeneratedSource generatedSource = new GeneratedSource(); + @Test @WithClasses({ ExtendsBoundSourceTargetMapper.class, @@ -59,7 +64,10 @@ public class WildCardTest { assertThat( target ).isNotNull(); assertThat( target.getElements() ).isNull(); - + generatedSource.forMapper( ExtendsBoundSourceTargetMapper.class ) + .content() + .as( "Should not contain FQN after extends" ) + .doesNotContain( "? extends org.mapstruct.ap.test.collection.wildcard.Idea" ); } @Test @@ -78,7 +86,10 @@ public class WildCardTest { assertThat( target ).isNotNull(); assertThat( target.getElements() ).isNull(); - + generatedSource.forMapper( SourceSuperBoundTargetMapper.class ) + .content() + .as( "Should not contain FQN after super" ) + .doesNotContain( "? super org.mapstruct.ap.test.collection.wildcard.Idea" ); } @Test