From b249c2ced10441619e606c15fa489e502a15b801 Mon Sep 17 00:00:00 2001 From: sjaak Date: Tue, 31 Dec 2013 13:17:29 +0100 Subject: [PATCH] Issue #79 Adding generics solution for custom mappers --- .../ap/processor/MapperCreationProcessor.java | 9 +- .../org/mapstruct/ap/util/MethodMatcher.java | 326 ++++++++++++++++++ .../conversion/generics/ArrayWrapper.java | 39 +++ .../conversion/generics/ConversionTest.java | 179 ++++++++++ .../conversion/generics/ErroneousSource1.java | 32 ++ .../conversion/generics/ErroneousSource2.java | 32 ++ .../conversion/generics/ErroneousSource3.java | 32 ++ .../conversion/generics/ErroneousSource4.java | 32 ++ .../conversion/generics/ErroneousSource5.java | 32 ++ .../ErroneousSourceTargetMapper1.java | 30 ++ .../ErroneousSourceTargetMapper2.java | 30 ++ .../ErroneousSourceTargetMapper3.java | 30 ++ .../ErroneousSourceTargetMapper4.java | 30 ++ .../ErroneousSourceTargetMapper5.java | 30 ++ .../conversion/generics/ErroneousTarget1.java | 32 ++ .../conversion/generics/ErroneousTarget2.java | 33 ++ .../conversion/generics/ErroneousTarget3.java | 33 ++ .../conversion/generics/ErroneousTarget4.java | 33 ++ .../conversion/generics/ErroneousTarget5.java | 33 ++ .../generics/GenericTypeMapper.java | 72 ++++ .../ap/test/conversion/generics/Source.java | 142 ++++++++ .../generics/SourceTargetMapper.java | 30 ++ .../ap/test/conversion/generics/Target.java | 142 ++++++++ .../conversion/generics/TwoArgHolder.java | 49 +++ .../conversion/generics/TwoArgWrapper.java | 39 +++ .../ap/test/conversion/generics/TypeA.java | 25 ++ .../ap/test/conversion/generics/TypeB.java | 25 ++ .../ap/test/conversion/generics/TypeC.java | 27 ++ .../generics/UpperBoundWrapper.java | 39 +++ .../generics/WildCardExtendsMBWrapper.java | 40 +++ .../generics/WildCardExtendsWrapper.java | 39 +++ .../generics/WildCardSuperWrapper.java | 39 +++ .../ap/test/conversion/generics/Wrapper.java | 39 +++ 33 files changed, 1769 insertions(+), 5 deletions(-) create mode 100644 processor/src/main/java/org/mapstruct/ap/util/MethodMatcher.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ArrayWrapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ConversionTest.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource1.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource2.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource3.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource4.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource5.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper1.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper2.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper3.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper4.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper5.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget1.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget2.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget3.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget4.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget5.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/GenericTypeMapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Source.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/SourceTargetMapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Target.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgHolder.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgWrapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeA.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeB.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeC.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/UpperBoundWrapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsMBWrapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsWrapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardSuperWrapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Wrapper.java diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java index ec028d7d0..3bceef923 100644 --- a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java @@ -61,6 +61,7 @@ import org.mapstruct.ap.model.source.Mapping; import org.mapstruct.ap.model.source.Method; import org.mapstruct.ap.util.Executables; import org.mapstruct.ap.util.Filters; +import org.mapstruct.ap.util.MethodMatcher; import org.mapstruct.ap.util.Strings; import org.mapstruct.ap.util.TypeFactory; @@ -546,13 +547,11 @@ public class MapperCreationProcessor implements ModelElementProcessor T getResult(? extends T) throws Exception + * \-------------------------------/ \-/ \---------/ + * TypeParameters Result ParameterList + * + * Matches a given method with given ParameterList and Result type obeying the + * constraints in the TypeParameters block. + * + * For more info on java-generics: + * http://www.javacodegeeks.com/2011/04/java-generics-quick-tutorial.html + * http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html + * + * The following situations is not supported / tested: + * 1) Multiple bounds were the bound itself is again a generic type. + * + * @author Sjaak Derksen + */ +public class MethodMatcher { + + private final Type[] parameters; + private final Type returnType; + private final Method candidateMethod; + private final Types typeUtils; + private boolean typesMatch = true; + private Map genericTypesMap = new HashMap(); + + public MethodMatcher(Types typeUtils, Method candidateMethod, Type returnType, Type... arguments) { + this.typeUtils = typeUtils; + this.candidateMethod = candidateMethod; + this.parameters = arguments; + this.returnType = returnType; + } + + public boolean matches() { + + // check & collect generic types. + List candidateParameters = candidateMethod.getExecutable().getParameters(); + if ( candidateParameters.size() == parameters.length ) { + for ( int i = 0; i < parameters.length; i++ ) { + TypeMatcher parameterMatcher = new TypeMatcher(); + parameterMatcher.visit( candidateParameters.get( i ).asType(), parameters[i].getTypeMirror() ); + if ( !typesMatch ) { + break; + } + } + } + else { + typesMatch = false; + } + + // check return type + if ( typesMatch ) { + TypeMirror candidateReturnType = candidateMethod.getExecutable().getReturnType(); + TypeMatcher returnTypeMatcher = new TypeMatcher(); + returnTypeMatcher.visit( candidateReturnType, returnType.getTypeMirror() ); + } + + // check if all type parameters are indeed mapped + if ( candidateMethod.getExecutable().getTypeParameters().size() != this.genericTypesMap.size() ) { + typesMatch = false; + } + else { + // check if all entries are in the bounds + for (Map.Entry entry : genericTypesMap.entrySet()) { + if (!isWithinBounds( entry.getValue(), getTypeParamFromCandite( entry.getKey() ) ) ) { + // checks if the found Type is in bounds of the TypeParameters bounds. + typesMatch = false; + } + } + } + return typesMatch; + } + + public class TypeMatcher extends AbstractTypeVisitor6 { + + @Override + public TypeMirror visitPrimitive(PrimitiveType t, TypeMirror p) { + if ( !typeUtils.isSameType( t, p ) ) { + typesMatch = false; + } + return null; + } + + @Override + public TypeMirror visitNull(NullType t, TypeMirror p) { + // not interesting + return null; + } + + @Override + public TypeMirror visitArray(ArrayType t, TypeMirror p) { + + if ( p instanceof ArrayType ) { + t.getComponentType().accept( this, ( (ArrayType) p ).getComponentType() ); + } + else { + typesMatch = false; + } + return null; + } + + @Override + public TypeMirror visitDeclared(DeclaredType t, TypeMirror p) { + // its a match when: 1) same kind of type, name is equals, nr of type args are the same + // (type args are checked later). + if ( p instanceof DeclaredType ) { + DeclaredType t1 = (DeclaredType) p; + if ( t.asElement().getSimpleName().equals( t1.asElement().getSimpleName() ) + && t.getTypeArguments().size() == t1.getTypeArguments().size() ) { + for ( int i = 0; i < t.getTypeArguments().size(); i++ ) { + t.getTypeArguments().get( i ).accept( this, t1.getTypeArguments().get( i ) ); + } + } + else { + typesMatch = false; + } + } + else { + typesMatch = false; + } + return null; + } + + @Override + public TypeMirror visitError(ErrorType t, TypeMirror p) { + // not interesting + return null; + } + + @Override + public TypeMirror visitTypeVariable(TypeVariable t, TypeMirror p) { + if ( genericTypesMap.containsKey( t ) ) { + // when already found, the same mapping should apply + TypeMirror p1 = genericTypesMap.get( t ); + if ( !typeUtils.isSameType( p, p1 ) ) { + typesMatch = false; + } + } + else { + // check if types are in bound + if ( typeUtils.isSubtype( t.getLowerBound(), p ) && typeUtils.isSubtype( p, t.getUpperBound() ) ) { + genericTypesMap.put( t, p ); + } + else { + typesMatch = false; + } + } + return null; + } + + @Override + public TypeMirror visitWildcard(WildcardType t, TypeMirror p) { + + // check extends bound + TypeMirror extendsBound = t.getExtendsBound(); + if ( extendsBound != null ) { + switch ( extendsBound.getKind() ) { + case DECLARED: + // for example method: String method(? extends String) + if ( !typeUtils.isSubtype( p, extendsBound ) ) { + // isSubType checks range [subtype, type], e.g. isSubtype [Object, String]==true + typesMatch = false; + } + break; + + case TYPEVAR: + // for exampe method: T method(? extends T) + // this can be done the directly by checking: ? extends String & Serializable + if ( !isWithinBounds( p, getTypeParamFromCandite( extendsBound ) ) ) { + // this checks the part? + typesMatch = false; + } + break; + + default: + // does this situation occur? + typesMatch = false; + } + } + + // check super bound + TypeMirror superBound = t.getSuperBound(); + if ( superBound != null ) { + switch ( superBound.getKind() ) { + case DECLARED: + // for example method: String method(? super String) + if ( !( typeUtils.isSubtype( superBound, p ) || typeUtils.isSameType( p, superBound ) ) ) { + // to check super type, we can simply reverse the argument, but that would initially yield + // a result: T method(? super T) + if ( !isWithinBounds( p, typeParameter ) ) { + // this checks the part? + typesMatch = false; + } + // now, it becoms a bit more hairy. We have the relation (? super T). From T we know that + // it is a subclass of String & Serializable. However, The Java Language Secification, + // Chapter 4.4, states that a bound is either: 'A type variable-', 'A class-' or 'An + // interface-' type followed by further interface types. So we must compare with the first + // argument in the Expression String & Serializable & ..., so, in this case String. + TypeMirror superBoundAsDeclared = typeParameter.getBounds().get( 0 ); + if ( !( typeUtils.isSubtype( superBoundAsDeclared, p ) || + typeUtils.isSameType( p, superBoundAsDeclared ) ) ) { + // to check super type, we can simply reverse the argument, but that would initially yield + // a result: bounds = tpe.getBounds(); + if ( t != null && bounds != null ) { + for ( TypeMirror bound : bounds ) { + if ( !( bound.getKind().equals( TypeKind.DECLARED ) && + typeUtils.isSubtype( t, (DeclaredType) bound ) ) ) { + return false; + } + } + return true; + } + return false; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ArrayWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ArrayWrapper.java new file mode 100644 index 000000000..27221d5e9 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ArrayWrapper.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ArrayWrapper { + + public ArrayWrapper() { + } + + public ArrayWrapper(T[] wrapped) { + this.wrapped = wrapped; + } + + private T[] wrapped; + + public T[] getWrapped() { + return wrapped; + } + + public void setWrapped(T[] wrapped) { + this.wrapped = wrapped; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ConversionTest.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ConversionTest.java new file mode 100644 index 000000000..98dbbb2cd --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ConversionTest.java @@ -0,0 +1,179 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import java.math.BigDecimal; +import org.mapstruct.ap.testutil.MapperTestBase; +import org.mapstruct.ap.testutil.WithClasses; +import org.testng.annotations.Test; + +import static org.fest.assertions.Assertions.assertThat; +import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; +import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; +import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; + +public class ConversionTest extends MapperTestBase { + + @Test + @WithClasses( { ErroneousSource1.class, ErroneousTarget1.class, ErroneousSource2.class, ErroneousTarget2.class, + ErroneousSource3.class, ErroneousTarget3.class, ErroneousSource4.class, ErroneousTarget4.class, + ErroneousSource5.class, ErroneousTarget5.class, + GenericTypeMapper.class, Wrapper.class, ArrayWrapper.class, TwoArgHolder.class, TwoArgWrapper.class, + TypeA.class, TypeB.class, TypeC.class, UpperBoundWrapper.class, Source.class, Target.class, + WildCardExtendsWrapper.class, WildCardSuperWrapper.class, WildCardExtendsMBWrapper.class, + SourceTargetMapper.class } ) + public void shouldApplyGenericTypeMapper() { + + // setup used types + TypeB typeB = new TypeB(); + TypeC typeC = new TypeC(); + + // setup source + Source source = new Source(); + source.setFooInteger( new Wrapper( 5 ) ); + source.setFooString( new Wrapper( "test" ) ); + source.setFooStringArray( new Wrapper( new String[] { "test1", "test2" } ) ); + source.setFooLongArray( new ArrayWrapper( new Long[] { 5L, 3L } ) ); + source.setFooTwoArgs( new TwoArgWrapper( new TwoArgHolder( 3, true ) ) ); + source.setFooNested( new Wrapper>( new Wrapper( new BigDecimal( 5 ) ) ) ); + source.setFooUpperBoundCorrect( new UpperBoundWrapper( typeB ) ); + source.setFooWildCardExtendsString( new WildCardExtendsWrapper( "test3" ) ); + source.setFooWildCardExtendsTypeCCorrect( new WildCardExtendsWrapper( typeC ) ); + source.setFooWildCardExtendsTypeBCorrect( new WildCardExtendsWrapper( typeB ) ); + source.setFooWildCardSuperString( new WildCardSuperWrapper( "test4" ) ); + source.setFooWildCardExtendsMBTypeCCorrect( new WildCardExtendsMBWrapper( typeC ) ); + source.setFooWildCardSuperTypeBCorrect( new WildCardSuperWrapper( typeB ) ); + + // define wrapper + Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); + + // assert results + assertThat( target ).isNotNull(); + assertThat( target.getFooInteger() ).isEqualTo( 5 ); + assertThat( target.getFooString() ).isEqualTo( "test" ); + assertThat( target.getFooStringArray() ).isEqualTo( new String[] { "test1", "test2" } ); + assertThat( target.getFooLongArray() ).isEqualTo( new Long[] { 5L, 3L } ); + assertThat( target.getFooTwoArgs().getArg1() ).isEqualTo( 3 ); + assertThat( target.getFooTwoArgs().getArg2() ).isEqualTo( true ); + assertThat( target.getFooNested() ).isEqualTo( new BigDecimal( 5 ) ); + assertThat( target.getFooUpperBoundCorrect() ).isEqualTo( typeB ); + assertThat( target.getFooWildCardExtendsString() ).isEqualTo( "test3" ); + assertThat( target.getFooWildCardExtendsTypeCCorrect() ).isEqualTo( typeC ); + assertThat( target.getFooWildCardExtendsTypeBCorrect() ).isEqualTo( typeB ); + assertThat( target.getFooWildCardSuperString() ).isEqualTo( "test4" ); + assertThat( target.getFooWildCardExtendsMBTypeCCorrect() ).isEqualTo( typeC ); + assertThat( target.getFooWildCardSuperTypeBCorrect() ).isEqualTo( typeB ); + + } + + @Test + @WithClasses({ErroneousSource1.class, ErroneousTarget1.class, ErroneousSource2.class, ErroneousTarget2.class, + ErroneousSource3.class, ErroneousTarget3.class, ErroneousSource4.class, ErroneousTarget4.class, + ErroneousSource5.class, ErroneousTarget5.class, + GenericTypeMapper.class, Wrapper.class, ArrayWrapper.class, TwoArgHolder.class, TwoArgWrapper.class, + TypeA.class, TypeB.class, TypeC.class, UpperBoundWrapper.class, Source.class, Target.class, + WildCardExtendsWrapper.class, WildCardSuperWrapper.class, WildCardExtendsMBWrapper.class, + ErroneousSourceTargetMapper1.class } ) + @ExpectedCompilationOutcome(value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = ErroneousSourceTargetMapper1.class, + kind = javax.tools.Diagnostic.Kind.ERROR, line = 29, + messageRegExp = "Can't map property \"org.mapstruct.ap.test.conversion.generics.UpperBoundWrapper" + + " fooUpperBoundFailure\" to " + + "\"org.mapstruct.ap.test.conversion.generics.TypeA fooUpperBoundFailure\"") } ) + public void shouldFailOnUpperBound() { + } + + @Test + @WithClasses({ErroneousSource1.class, ErroneousTarget1.class, ErroneousSource2.class, ErroneousTarget2.class, + ErroneousSource3.class, ErroneousTarget3.class, ErroneousSource4.class, ErroneousTarget4.class, + ErroneousSource5.class, ErroneousTarget5.class, + GenericTypeMapper.class, Wrapper.class, ArrayWrapper.class, TwoArgHolder.class, TwoArgWrapper.class, + TypeA.class, TypeB.class, TypeC.class, UpperBoundWrapper.class, Source.class, Target.class, + WildCardExtendsWrapper.class, WildCardSuperWrapper.class, WildCardExtendsMBWrapper.class, + ErroneousSourceTargetMapper2.class } ) + @ExpectedCompilationOutcome(value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = ErroneousSourceTargetMapper2.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 29, + messageRegExp = "Can't map property \"org.mapstruct.ap.test.conversion.generics.WildCardExtendsWrapper" + + " fooWildCardExtendsTypeAFailure\" to" + + " \"org.mapstruct.ap.test.conversion.generics.TypeA fooWildCardExtendsTypeAFailure\"" ) } ) + public void shouldFailOnWildCardBound() { + } + + @Test + @WithClasses({ErroneousSource1.class, ErroneousTarget1.class, ErroneousSource2.class, ErroneousTarget2.class, + ErroneousSource3.class, ErroneousTarget3.class, ErroneousSource4.class, ErroneousTarget4.class, + ErroneousSource5.class, ErroneousTarget5.class, + GenericTypeMapper.class, Wrapper.class, ArrayWrapper.class, TwoArgHolder.class, TwoArgWrapper.class, + TypeA.class, TypeB.class, TypeC.class, UpperBoundWrapper.class, Source.class, Target.class, + WildCardExtendsWrapper.class, WildCardSuperWrapper.class, WildCardExtendsMBWrapper.class, + ErroneousSourceTargetMapper3.class } ) + @ExpectedCompilationOutcome(value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = ErroneousSourceTargetMapper3.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 29, + messageRegExp = "Can't map property \"org.mapstruct.ap.test.conversion.generics." + + "WildCardExtendsMBWrapper " + + "fooWildCardExtendsMBTypeBFailure\" to \"org.mapstruct.ap.test.conversion.generics.TypeB " + + "fooWildCardExtendsMBTypeBFailure\"" ) } ) + public void shouldFailOnWildCardMultipleBounds() { + } + + @Test + @WithClasses({ErroneousSource1.class, ErroneousTarget1.class, ErroneousSource2.class, ErroneousTarget2.class, + ErroneousSource3.class, ErroneousTarget3.class, ErroneousSource4.class, ErroneousTarget4.class, + ErroneousSource5.class, ErroneousTarget5.class, + GenericTypeMapper.class, Wrapper.class, ArrayWrapper.class, TwoArgHolder.class, TwoArgWrapper.class, + TypeA.class, TypeB.class, TypeC.class, UpperBoundWrapper.class, Source.class, Target.class, + WildCardExtendsWrapper.class, WildCardSuperWrapper.class, WildCardExtendsMBWrapper.class, + ErroneousSourceTargetMapper4.class } ) + @ExpectedCompilationOutcome(value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = ErroneousSourceTargetMapper4.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 29, + messageRegExp = "Can't map property \"org.mapstruct.ap.test.conversion.generics.WildCardSuperWrapper" + + " fooWildCardSuperTypeAFailure\" to" + + " \"org.mapstruct.ap.test.conversion.generics.TypeA fooWildCardSuperTypeAFailure\"" ) } ) + public void shouldFailOnSuperBounds1() { + } + + @Test + @WithClasses({ErroneousSource1.class, ErroneousTarget1.class, ErroneousSource2.class, ErroneousTarget2.class, + ErroneousSource3.class, ErroneousTarget3.class, ErroneousSource4.class, ErroneousTarget4.class, + ErroneousSource5.class, ErroneousTarget5.class, + GenericTypeMapper.class, Wrapper.class, ArrayWrapper.class, TwoArgHolder.class, TwoArgWrapper.class, + TypeA.class, TypeB.class, TypeC.class, UpperBoundWrapper.class, Source.class, Target.class, + WildCardExtendsWrapper.class, WildCardSuperWrapper.class, WildCardExtendsMBWrapper.class, + ErroneousSourceTargetMapper5.class } ) + @ExpectedCompilationOutcome(value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = ErroneousSourceTargetMapper5.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 29, + messageRegExp = "Can't map property \"org.mapstruct.ap.test.conversion.generics.WildCardSuperWrapper" + + " fooWildCardSuperTypeCFailure\" to" + + " \"org.mapstruct.ap.test.conversion.generics.TypeC fooWildCardSuperTypeCFailure\"" ) } ) + public void shouldFailOnSuperBounds2() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource1.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource1.java new file mode 100644 index 000000000..23331392c --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource1.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousSource1 { + + private UpperBoundWrapper fooUpperBoundFailure; + + public UpperBoundWrapper getFooUpperBoundFailure() { + return fooUpperBoundFailure; + } + + public void setFooUpperBoundFailure(UpperBoundWrapper fooUpperBoundFailure) { + this.fooUpperBoundFailure = fooUpperBoundFailure; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource2.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource2.java new file mode 100644 index 000000000..aef2cdaab --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource2.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousSource2 { + + private WildCardExtendsWrapper fooWildCardExtendsTypeAFailure; + + public WildCardExtendsWrapper getFooWildCardExtendsTypeAFailure() { + return fooWildCardExtendsTypeAFailure; + } + + public void setFooWildCardExtendsTypeAFailure(WildCardExtendsWrapper fooWildCardExtendsTypeAFailure) { + this.fooWildCardExtendsTypeAFailure = fooWildCardExtendsTypeAFailure; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource3.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource3.java new file mode 100644 index 000000000..e39b70370 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource3.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousSource3 { + + private WildCardExtendsMBWrapper fooWildCardExtendsMBTypeBFailure; + + public WildCardExtendsMBWrapper getFooWildCardExtendsMBTypeBFailure() { + return fooWildCardExtendsMBTypeBFailure; + } + + public void setFooWildCardExtendsMBTypeBFailure(WildCardExtendsMBWrapper fooWildCardExtendsMBTypeBFailure) { + this.fooWildCardExtendsMBTypeBFailure = fooWildCardExtendsMBTypeBFailure; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource4.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource4.java new file mode 100644 index 000000000..a30b0f47f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource4.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousSource4 { + + private WildCardSuperWrapper fooWildCardSuperTypeAFailure; + + public WildCardSuperWrapper getFooWildCardSuperTypeAFailure() { + return fooWildCardSuperTypeAFailure; + } + + public void setFooWildCardSuperTypeAFailure(WildCardSuperWrapper fooWildCardSuperTypeAFailure) { + this.fooWildCardSuperTypeAFailure = fooWildCardSuperTypeAFailure; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource5.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource5.java new file mode 100644 index 000000000..386fbd2bb --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSource5.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousSource5 { + + private WildCardSuperWrapper fooWildCardSuperTypeCFailure; + + public WildCardSuperWrapper getFooWildCardSuperTypeCFailure() { + return fooWildCardSuperTypeCFailure; + } + + public void setFooWildCardSuperTypeCFailure(WildCardSuperWrapper fooWildCardSuperTypeCFailure) { + this.fooWildCardSuperTypeCFailure = fooWildCardSuperTypeCFailure; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper1.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper1.java new file mode 100644 index 000000000..5aca2b432 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper1.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( uses = GenericTypeMapper.class ) +public interface ErroneousSourceTargetMapper1 { + + ErroneousSourceTargetMapper1 INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper1.class ); + + ErroneousTarget1 sourceToTarget(ErroneousSource1 source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper2.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper2.java new file mode 100644 index 000000000..5f40e6bba --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper2.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( uses = GenericTypeMapper.class ) +public interface ErroneousSourceTargetMapper2 { + + ErroneousSourceTargetMapper2 INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper2.class ); + + ErroneousTarget2 sourceToTarget(ErroneousSource2 source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper3.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper3.java new file mode 100644 index 000000000..c0b4d8bdc --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper3.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( uses = GenericTypeMapper.class ) +public interface ErroneousSourceTargetMapper3 { + + ErroneousSourceTargetMapper3 INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper3.class ); + + ErroneousTarget3 sourceToTarget(ErroneousSource3 source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper4.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper4.java new file mode 100644 index 000000000..148485335 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper4.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( uses = GenericTypeMapper.class ) +public interface ErroneousSourceTargetMapper4 { + + ErroneousSourceTargetMapper4 INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper4.class ); + + ErroneousTarget4 sourceToTarget(ErroneousSource4 source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper5.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper5.java new file mode 100644 index 000000000..179608dcf --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousSourceTargetMapper5.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( uses = GenericTypeMapper.class ) +public interface ErroneousSourceTargetMapper5 { + + ErroneousSourceTargetMapper5 INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper5.class ); + + ErroneousTarget5 sourceToTarget(ErroneousSource5 source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget1.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget1.java new file mode 100644 index 000000000..22c6ad7ac --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget1.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousTarget1 { + + private TypeA fooUpperBoundFailure; + + public TypeA getFooUpperBoundFailure() { + return fooUpperBoundFailure; + } + + public void setFooUpperBoundFailure(TypeA fooUpperBoundFailure) { + this.fooUpperBoundFailure = fooUpperBoundFailure; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget2.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget2.java new file mode 100644 index 000000000..c82e30256 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget2.java @@ -0,0 +1,33 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousTarget2 { + + private TypeA fooWildCardExtendsTypeAFailure; + + public TypeA getFooWildCardExtendsTypeAFailure() { + return fooWildCardExtendsTypeAFailure; + } + + public void setFooWildCardExtendsTypeAFailure(TypeA fooWildCardExtendsTypeAFailure) { + this.fooWildCardExtendsTypeAFailure = fooWildCardExtendsTypeAFailure; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget3.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget3.java new file mode 100644 index 000000000..ccfb71447 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget3.java @@ -0,0 +1,33 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousTarget3 { + + private TypeB fooWildCardExtendsMBTypeBFailure; + + public TypeB getFooWildCardExtendsMBTypeBFailure() { + return fooWildCardExtendsMBTypeBFailure; + } + + public void setFooWildCardExtendsMBTypeBFailure(TypeB fooWildCardExtendsMBTypeBFailure) { + this.fooWildCardExtendsMBTypeBFailure = fooWildCardExtendsMBTypeBFailure; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget4.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget4.java new file mode 100644 index 000000000..3d5fbf7e4 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget4.java @@ -0,0 +1,33 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousTarget4 { + + private TypeA fooWildCardSuperTypeAFailure; + + public TypeA getFooWildCardSuperTypeAFailure() { + return fooWildCardSuperTypeAFailure; + } + + public void setFooWildCardSuperTypeAFailure(TypeA fooWildCardSuperTypeAFailure) { + this.fooWildCardSuperTypeAFailure = fooWildCardSuperTypeAFailure; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget5.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget5.java new file mode 100644 index 000000000..e9584a15d --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/ErroneousTarget5.java @@ -0,0 +1,33 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class ErroneousTarget5 { + + private TypeC fooWildCardSuperTypeCFailure; + + public TypeC getFooWildCardSuperTypeCFailure() { + return fooWildCardSuperTypeCFailure; + } + + public void setFooWildCardSuperTypeCFailure(TypeC fooWildCardSuperTypeCFailure) { + this.fooWildCardSuperTypeCFailure = fooWildCardSuperTypeCFailure; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/GenericTypeMapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/GenericTypeMapper.java new file mode 100644 index 000000000..822e4f5f5 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/GenericTypeMapper.java @@ -0,0 +1,72 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import java.io.Serializable; + +public class GenericTypeMapper { + + public T getWrapped(Wrapper source) { + return source.getWrapped(); + } + + public T[] getArrayWrapped(ArrayWrapper t) { + return t.getWrapped(); + } + + public TwoArgHolder getTwoArgWrapped(TwoArgWrapper t) { + return t.getWrapped(); + } + + public T getNestedWrapped(Wrapper> t) { + return t.getWrapped().getWrapped(); + } + + public T getUpperBounded(UpperBoundWrapper t) { + return t.getWrapped(); + } + + // TODO Lower bound test? The javadoc states: Returns the lower bound of this type variable. + // While a type parameter cannot include an explicit lower bound declaration, capture conversion can produce + // a type variable with a non-trivial lower bound. Type variables otherwise have a lower bound of NullType. + + public String getWildCardExtendsString(WildCardExtendsWrapper t) { + return t.getWrapped(); + } + + public T getWildCardExtendsType(WildCardExtendsWrapper t) { + return t.getWrapped(); + } + + /** + * TODO.. My own IDE compiler actually allows all TypeA, TypeB, TypeC. However, I assume + * that only TypeB is allowed here. This is what the code actually enforces. + */ + public T getWildCardSuperType(WildCardSuperWrapper t) { + return (T) t.getWrapped(); + } + + public String getWildCardSupersString(WildCardSuperWrapper t) { + return (String) t.getWrapped(); + } + + public T getWildCardExtendsMBType(WildCardExtendsMBWrapper t) { + return t.getWrapped(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Source.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Source.java new file mode 100644 index 000000000..3529efc7f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Source.java @@ -0,0 +1,142 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import java.math.BigDecimal; + +public class Source { + + private Wrapper fooInteger; + private Wrapper fooString; + private Wrapper fooStringArray; + private ArrayWrapper fooLongArray; + private TwoArgWrapper fooTwoArgs; + private Wrapper> fooNested; + private UpperBoundWrapper fooUpperBoundCorrect; + private WildCardExtendsWrapper fooWildCardExtendsString; + private WildCardExtendsWrapper fooWildCardExtendsTypeCCorrect; + private WildCardExtendsWrapper fooWildCardExtendsTypeBCorrect; + private WildCardSuperWrapper fooWildCardSuperString; + private WildCardExtendsMBWrapper fooWildCardExtendsMBTypeCCorrect; + private WildCardSuperWrapper fooWildCardSuperTypeBCorrect; + + public Wrapper getFooInteger() { + return fooInteger; + } + + public void setFooInteger(Wrapper fooInteger) { + this.fooInteger = fooInteger; + } + + public Wrapper getFooString() { + return fooString; + } + + public void setFooString(Wrapper fooString) { + this.fooString = fooString; + } + + public Wrapper getFooStringArray() { + return fooStringArray; + } + + public void setFooStringArray(Wrapper fooStringArray) { + this.fooStringArray = fooStringArray; + } + + public ArrayWrapper getFooLongArray() { + return fooLongArray; + } + + public void setFooLongArray(ArrayWrapper fooLongArray) { + this.fooLongArray = fooLongArray; + } + + public TwoArgWrapper getFooTwoArgs() { + return fooTwoArgs; + } + + public void setFooTwoArgs(TwoArgWrapper fooTwoArgs) { + this.fooTwoArgs = fooTwoArgs; + } + + public Wrapper> getFooNested() { + return fooNested; + } + + public void setFooNested(Wrapper> fooNested) { + this.fooNested = fooNested; + } + + public UpperBoundWrapper getFooUpperBoundCorrect() { + return fooUpperBoundCorrect; + } + + public void setFooUpperBoundCorrect(UpperBoundWrapper fooUpperBoundCorrect) { + this.fooUpperBoundCorrect = fooUpperBoundCorrect; + } + + public WildCardExtendsWrapper getFooWildCardExtendsString() { + return fooWildCardExtendsString; + } + + public void setFooWildCardExtendsString(WildCardExtendsWrapper fooWildCardExtendsString) { + this.fooWildCardExtendsString = fooWildCardExtendsString; + } + + public void setFooWildCardExtendsTypeCCorrect(WildCardExtendsWrapper fooWildCardExtendsTypeCCorrect) { + this.fooWildCardExtendsTypeCCorrect = fooWildCardExtendsTypeCCorrect; + } + + public WildCardExtendsWrapper getFooWildCardExtendsTypeCCorrect() { + return fooWildCardExtendsTypeCCorrect; + } + + public WildCardExtendsWrapper getFooWildCardExtendsTypeBCorrect() { + return fooWildCardExtendsTypeBCorrect; + } + + public void setFooWildCardExtendsTypeBCorrect(WildCardExtendsWrapper fooWildCardExtendsTypeBCorrect) { + this.fooWildCardExtendsTypeBCorrect = fooWildCardExtendsTypeBCorrect; + } + + public WildCardSuperWrapper getFooWildCardSuperString() { + return fooWildCardSuperString; + } + + public void setFooWildCardSuperString(WildCardSuperWrapper fooWildCardSuperString) { + this.fooWildCardSuperString = fooWildCardSuperString; + } + + public WildCardExtendsMBWrapper getFooWildCardExtendsMBTypeCCorrect() { + return fooWildCardExtendsMBTypeCCorrect; + } + + public void setFooWildCardExtendsMBTypeCCorrect(WildCardExtendsMBWrapper fooWildCardExtendsMBTypeCCorrect) { + this.fooWildCardExtendsMBTypeCCorrect = fooWildCardExtendsMBTypeCCorrect; + } + + public WildCardSuperWrapper getFooWildCardSuperTypeBCorrect() { + return fooWildCardSuperTypeBCorrect; + } + + public void setFooWildCardSuperTypeBCorrect(WildCardSuperWrapper fooWildCardSuperTypeBCorrect) { + this.fooWildCardSuperTypeBCorrect = fooWildCardSuperTypeBCorrect; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/SourceTargetMapper.java new file mode 100644 index 000000000..6080c2f95 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/SourceTargetMapper.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( uses = GenericTypeMapper.class ) +public interface SourceTargetMapper { + + SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); + + Target sourceToTarget(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Target.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Target.java new file mode 100644 index 000000000..360694170 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Target.java @@ -0,0 +1,142 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import java.math.BigDecimal; + +public class Target { + + private Integer fooInteger; + private String fooString; + private String[] fooStringArray; + private Long[] fooLongArray; + private TwoArgHolder fooTwoArgs; + private BigDecimal fooNested; + private TypeB fooUpperBoundCorrect; + private String fooWildCardExtendsString; + private TypeC fooWildCardExtendsTypeCCorrect; + private TypeB fooWildCardExtendsTypeBCorrect; + private String fooWildCardSuperString; + private TypeC fooWildCardExtendsMBTypeCCorrect; + private TypeB fooWildCardSuperTypeBCorrect; + + public Integer getFooInteger() { + return fooInteger; + } + + public void setFooInteger(Integer fooInteger) { + this.fooInteger = fooInteger; + } + + public String getFooString() { + return fooString; + } + + public void setFooString(String fooString) { + this.fooString = fooString; + } + + public String[] getFooStringArray() { + return fooStringArray; + } + + public void setFooStringArray(String[] fooStringArray) { + this.fooStringArray = fooStringArray; + } + + public Long[] getFooLongArray() { + return fooLongArray; + } + + public void setFooLongArray(Long[] fooLongArray) { + this.fooLongArray = fooLongArray; + } + + public TwoArgHolder getFooTwoArgs() { + return fooTwoArgs; + } + + public void setFooTwoArgs(TwoArgHolder fooTwoArgs) { + this.fooTwoArgs = fooTwoArgs; + } + + public BigDecimal getFooNested() { + return fooNested; + } + + public void setFooNested(BigDecimal fooNested) { + this.fooNested = fooNested; + } + + public TypeB getFooUpperBoundCorrect() { + return fooUpperBoundCorrect; + } + + public void setFooUpperBoundCorrect(TypeB fooUpperBoundCorrect) { + this.fooUpperBoundCorrect = fooUpperBoundCorrect; + } + + public String getFooWildCardExtendsString() { + return fooWildCardExtendsString; + } + + public void setFooWildCardExtendsString(String fooWildCardExtendsString) { + this.fooWildCardExtendsString = fooWildCardExtendsString; + } + + public TypeC getFooWildCardExtendsTypeCCorrect() { + return fooWildCardExtendsTypeCCorrect; + } + + public void setFooWildCardExtendsTypeCCorrect(TypeC fooWildCardExtendsTypeCCorrect) { + this.fooWildCardExtendsTypeCCorrect = fooWildCardExtendsTypeCCorrect; + } + + public TypeB getFooWildCardExtendsTypeBCorrect() { + return fooWildCardExtendsTypeBCorrect; + } + + public void setFooWildCardExtendsTypeBCorrect(TypeB fooWildCardExtendsTypeBCorrect) { + this.fooWildCardExtendsTypeBCorrect = fooWildCardExtendsTypeBCorrect; + } + + public String getFooWildCardSuperString() { + return fooWildCardSuperString; + } + + public void setFooWildCardSuperString(String fooWildCardSuperString) { + this.fooWildCardSuperString = fooWildCardSuperString; + } + + public TypeC getFooWildCardExtendsMBTypeCCorrect() { + return fooWildCardExtendsMBTypeCCorrect; + } + + public void setFooWildCardExtendsMBTypeCCorrect(TypeC fooWildCardExtendsMBTypeCCorrect) { + this.fooWildCardExtendsMBTypeCCorrect = fooWildCardExtendsMBTypeCCorrect; + } + + public TypeB getFooWildCardSuperTypeBCorrect() { + return fooWildCardSuperTypeBCorrect; + } + + public void setFooWildCardSuperTypeBCorrect(TypeB fooWildCardSuperTypeBCorrect) { + this.fooWildCardSuperTypeBCorrect = fooWildCardSuperTypeBCorrect; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgHolder.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgHolder.java new file mode 100644 index 000000000..352a362fe --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgHolder.java @@ -0,0 +1,49 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +/** + * @author sjaak + */ +public class TwoArgHolder { + + private T1 arg1; + private T2 arg2; + + public TwoArgHolder(T1 arg1, T2 arg2) { + this.arg1 = arg1; + this.arg2 = arg2; + } + + public T1 getArg1() { + return arg1; + } + + public void setArg1(T1 arg1) { + this.arg1 = arg1; + } + + public T2 getArg2() { + return arg2; + } + + public void setArg2(T2 arg2) { + this.arg2 = arg2; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgWrapper.java new file mode 100644 index 000000000..01c5d077d --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TwoArgWrapper.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class TwoArgWrapper { + + public TwoArgWrapper() { + } + + public TwoArgWrapper(TwoArgHolder wrapped) { + this.wrapped = wrapped; + } + + private TwoArgHolder wrapped; + + public TwoArgHolder getWrapped() { + return wrapped; + } + + public void setWrapped(TwoArgHolder wrapped) { + this.wrapped = wrapped; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeA.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeA.java new file mode 100644 index 000000000..c4acebc94 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeA.java @@ -0,0 +1,25 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class TypeA { + + public TypeA() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeB.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeB.java new file mode 100644 index 000000000..629e2a58b --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeB.java @@ -0,0 +1,25 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class TypeB extends TypeA { + + public TypeB() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeC.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeC.java new file mode 100644 index 000000000..d86f7d280 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/TypeC.java @@ -0,0 +1,27 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +import java.io.Serializable; + +public class TypeC extends TypeB implements Serializable { + + public TypeC() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/UpperBoundWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/UpperBoundWrapper.java new file mode 100644 index 000000000..bbe9a22e1 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/UpperBoundWrapper.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +/** + * @author sjaak + */ +public class UpperBoundWrapper { + + private T wrapped; + + public UpperBoundWrapper(T wrapped) { + this.wrapped = wrapped; + } + + public T getWrapped() { + return wrapped; + } + + public void setWrapped(T wrapped) { + this.wrapped = wrapped; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsMBWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsMBWrapper.java new file mode 100644 index 000000000..cebd09811 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsMBWrapper.java @@ -0,0 +1,40 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +/** + * Testing Multiple Bounds + * @author sjaak + */ +public class WildCardExtendsMBWrapper { + + private T wrapped; + + public WildCardExtendsMBWrapper(T wrapped) { + this.wrapped = wrapped; + } + + public T getWrapped() { + return wrapped; + } + + public void setWrapped(T wrapped) { + this.wrapped = wrapped; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsWrapper.java new file mode 100644 index 000000000..7a9196726 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardExtendsWrapper.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +/** + * @author sjaak + */ +public class WildCardExtendsWrapper { + + private T wrapped; + + public WildCardExtendsWrapper(T wrapped) { + this.wrapped = wrapped; + } + + public T getWrapped() { + return wrapped; + } + + public void setWrapped(T wrapped) { + this.wrapped = wrapped; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardSuperWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardSuperWrapper.java new file mode 100644 index 000000000..2bba5ac47 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/WildCardSuperWrapper.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +/** + * @author sjaak + */ +public class WildCardSuperWrapper { + + private T wrapped; + + public WildCardSuperWrapper(T wrapped) { + this.wrapped = wrapped; + } + + public T getWrapped() { + return wrapped; + } + + public void setWrapped(T wrapped) { + this.wrapped = wrapped; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Wrapper.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Wrapper.java new file mode 100644 index 000000000..d0cafc063 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/generics/Wrapper.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2013 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.conversion.generics; + +public class Wrapper { + + public Wrapper() { + } + + public Wrapper(T wrapped) { + this.wrapped = wrapped; + } + + private T wrapped; + + public T getWrapped() { + return wrapped; + } + + public void setWrapped(T wrapped) { + this.wrapped = wrapped; + } +}