diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java index f3a087049..62a9857e9 100644 --- a/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java @@ -69,7 +69,7 @@ public class MethodRetrievalProcessor implements ModelElementProcessor retrieveMethods(TypeElement element, boolean mapperRequiresImplementation) { + private List retrieveMethods(TypeElement usedMapper, TypeElement mapperToImplement) { List methods = new ArrayList(); - for ( ExecutableElement executable : methodsIn( allEnclosingElementsIncludeSuper( element ) ) ) { - SourceMethod method = getMethod( element, executable, mapperRequiresImplementation ); + for ( ExecutableElement executable : methodsIn( allEnclosingElementsIncludeSuper( usedMapper ) ) ) { + SourceMethod method = getMethod( usedMapper, executable, mapperToImplement ); if ( method != null ) { methods.add( method ); } } //Add all methods of used mappers in order to reference them in the aggregated model - if ( mapperRequiresImplementation ) { - MapperConfig mapperSettings = MapperConfig.getInstanceOn( element ); + if ( usedMapper.equals( mapperToImplement ) ) { + MapperConfig mapperSettings = MapperConfig.getInstanceOn( usedMapper ); if ( !mapperSettings.isValid() ) { throw new AnnotationProcessingException( - "Couldn't retrieve @Mapper annotation", element, mapperSettings.getAnnotationMirror() + "Couldn't retrieve @Mapper annotation", usedMapper, mapperSettings.getAnnotationMirror() ); } - for ( TypeMirror usedMapper : mapperSettings.uses() ) { - methods.addAll( retrieveMethods( asTypeElement( usedMapper ), false ) ); + for ( TypeMirror mapper : mapperSettings.uses() ) { + methods.addAll( retrieveMethods( asTypeElement( mapper ), mapperToImplement ) ); } } @@ -140,9 +138,9 @@ public class MethodRetrievalProcessor implements ModelElementProcessor parameters = typeFactory.getParameters( method ); Type returnType = typeFactory.getReturnType( method ); List exceptionTypes = typeFactory.getThrownTypes( method ); @@ -151,7 +149,7 @@ public class MethodRetrievalProcessor implements ModelElementProcessor sourceParameters = extractSourceParameters( parameters ); Parameter targetParameter = extractTargetParameter( parameters ); Type resultType = selectResultType( returnType, targetParameter ); @@ -184,15 +182,21 @@ public class MethodRetrievalProcessor implements ModelElementProcessor parameters) { for ( Parameter param : parameters ) { if ( param.isMappingTarget() ) { diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperPrivate.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperPrivate.java new file mode 100644 index 000000000..e95f4a637 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperPrivate.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper +public abstract class AbstractSourceTargetMapperPrivate extends SourceTargetmapperPrivateBase { + + public static final AbstractSourceTargetMapperPrivate INSTANCE = + Mappers.getMapper( AbstractSourceTargetMapperPrivate.class ); + + @Mapping(source = "referencedSource", target = "referencedTarget") + public abstract Target toTarget(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperProtected.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperProtected.java new file mode 100644 index 000000000..0a7125d67 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperProtected.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper +public abstract class AbstractSourceTargetMapperProtected extends SourceTargetmapperProtectedBase { + + public static final AbstractSourceTargetMapperProtected INSTANCE = + Mappers.getMapper( AbstractSourceTargetMapperProtected.class ); + + @Mapping(source = "referencedSource", target = "referencedTarget") + public abstract Target toTarget(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java new file mode 100644 index 000000000..a3a8f1069 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java @@ -0,0 +1,98 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mapstruct.ap.test.accessibility.referenced.a.ReferencedMapperDefaultOther; +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.WithClasses; +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; + +/** + * Test for different accessibility modifiers + * + * @author Sjaak Derksen + */ +@WithClasses( { Source.class, Target.class, ReferencedSource.class, ReferencedTarget.class } ) +@RunWith( AnnotationProcessorTestRunner.class ) +public class ReferencedAccessibilityTest { + + @Test + @IssueKey( "206" ) + @WithClasses( { SourceTargetMapperPrivate.class, ReferencedMapperPrivate.class } ) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic( type = SourceTargetMapperPrivate.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 35, + messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." + + "referenced\\.ReferencedSource referencedSource\" to \"org\\.mapstruct\\." + + "ap\\.test\\.accessibility\\.referenced\\.ReferencedTarget referencedTarget\"" ) + } + ) + public void shouldNotBeAbleToAccessPrivateMethodInReferenced() throws Exception { } + + @Test + @IssueKey( "206" ) + @WithClasses( { SourceTargetMapperDefaultSame.class, ReferencedMapperDefaultSame.class } ) + public void shouldBeAbleToAccessDefaultMethodInReferencedInSamePackage() throws Exception { } + + @Test + @IssueKey( "206" ) + @WithClasses( { SourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } ) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic( type = SourceTargetMapperDefaultOther.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 36, + messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." + + "referenced\\.ReferencedSource referencedSource\" to \"org\\.mapstruct\\." + + "ap\\.test\\.accessibility\\.referenced\\.ReferencedTarget referencedTarget\"" ) + } + ) + public void shouldNotBeAbleToAccessDefaultMethodInReferencedInOtherPackage() throws Exception { } + + @Test + @IssueKey( "206" ) + @WithClasses( { AbstractSourceTargetMapperProtected.class, SourceTargetmapperProtectedBase.class } ) + public void shouldBeAbleToAccessProtectedMethodInBase() throws Exception { } + + + @Test + @IssueKey( "206" ) + @WithClasses( { AbstractSourceTargetMapperPrivate.class, SourceTargetmapperPrivateBase.class } ) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic( type = AbstractSourceTargetMapperPrivate.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 36, + messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." + + "referenced\\.ReferencedSource referencedSource\" to \"org\\.mapstruct\\." + + "ap\\.test\\.accessibility\\.referenced\\.ReferencedTarget referencedTarget\"" ) + } + ) + public void shouldNotBeAbleToAccessPrivateMethodInBase() throws Exception { } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedMapperDefaultSame.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedMapperDefaultSame.java new file mode 100644 index 000000000..471b2dc63 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedMapperDefaultSame.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * + * @author Sjaak Derksen + */ +public class ReferencedMapperDefaultSame { + + ReferencedTarget sourceToTarget( ReferencedSource source ) { + ReferencedTarget target = new ReferencedTarget(); + target.setFoo( source.getFoo() ); + return target; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedMapperPrivate.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedMapperPrivate.java new file mode 100644 index 000000000..66ac68103 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedMapperPrivate.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * + * @author Sjaak Derksen + */ +public class ReferencedMapperPrivate { + + private ReferencedTarget sourceToTarget( ReferencedSource source ) { + ReferencedTarget target = new ReferencedTarget(); + target.setFoo( source.getFoo() ); + return target; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedSource.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedSource.java new file mode 100644 index 000000000..5a3d091bd --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedSource.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * @author Sjaak Derksen + */ +public class ReferencedSource { + private String foo; + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedTarget.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedTarget.java new file mode 100644 index 000000000..f39685d55 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedTarget.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * @author Sjaak Derksen + */ +public class ReferencedTarget { + private String foo; + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/Source.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/Source.java new file mode 100644 index 000000000..2e80459b7 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/Source.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * + * @author Sjaak Derksen + */ +public class Source { + + private ReferencedSource referencedSource; + + public ReferencedSource getReferencedSource() { + return referencedSource; + } + + public void setReferencedSource( ReferencedSource referencedSource ) { + this.referencedSource = referencedSource; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultOther.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultOther.java new file mode 100644 index 000000000..92e8f714e --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultOther.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ap.test.accessibility.referenced.a.ReferencedMapperDefaultOther; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper(uses = ReferencedMapperDefaultOther.class) +public interface SourceTargetMapperDefaultOther { + + SourceTargetMapperDefaultOther INSTANCE = Mappers.getMapper( SourceTargetMapperDefaultOther.class ); + + @Mapping(source = "referencedSource", target = "referencedTarget") + Target toTarget(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultSame.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultSame.java new file mode 100644 index 000000000..ffd284fc1 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultSame.java @@ -0,0 +1,36 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper(uses = ReferencedMapperDefaultSame.class) +public interface SourceTargetMapperDefaultSame { + + SourceTargetMapperDefaultSame INSTANCE = Mappers.getMapper( SourceTargetMapperDefaultSame.class ); + + @Mapping(source = "referencedSource", target = "referencedTarget") + Target toTarget(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperPrivate.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperPrivate.java new file mode 100644 index 000000000..87049f834 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperPrivate.java @@ -0,0 +1,36 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper(uses = ReferencedMapperPrivate.class) +public interface SourceTargetMapperPrivate { + + SourceTargetMapperPrivate INSTANCE = Mappers.getMapper( SourceTargetMapperPrivate.class ); + + @Mapping(source = "referencedSource", target = "referencedTarget") + Target toTarget(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetmapperPrivateBase.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetmapperPrivateBase.java new file mode 100644 index 000000000..31b4ce4c0 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetmapperPrivateBase.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * + * @author Sjaak Derksen + */ +public class SourceTargetmapperPrivateBase { + + private ReferencedTarget sourceToTarget( ReferencedSource source ) { + ReferencedTarget target = new ReferencedTarget(); + target.setFoo( source.getFoo() ); + return target; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetmapperProtectedBase.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetmapperProtectedBase.java new file mode 100644 index 000000000..b1e0702f2 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetmapperProtectedBase.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * + * @author Sjaak Derksen + */ +public class SourceTargetmapperProtectedBase { + + protected ReferencedTarget sourceToTarget( ReferencedSource source ) { + ReferencedTarget target = new ReferencedTarget(); + target.setFoo( source.getFoo() ); + return target; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/Target.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/Target.java new file mode 100644 index 000000000..75c8bdffe --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/Target.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced; + +/** + * + * @author Sjaak Derksen + */ +public class Target { + + private ReferencedTarget referencedTarget; + + public ReferencedTarget getReferencedTarget() { + return referencedTarget; + } + + public void setReferencedTarget( ReferencedTarget referencedTarget ) { + this.referencedTarget = referencedTarget; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/a/ReferencedMapperDefaultOther.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/a/ReferencedMapperDefaultOther.java new file mode 100644 index 000000000..b50e67ae7 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/a/ReferencedMapperDefaultOther.java @@ -0,0 +1,36 @@ +/** + * Copyright 2012-2014 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.accessibility.referenced.a; + +import org.mapstruct.ap.test.accessibility.referenced.ReferencedSource; +import org.mapstruct.ap.test.accessibility.referenced.ReferencedTarget; + + +/** + * + * @author Sjaak Derksen + */ +public class ReferencedMapperDefaultOther { + + ReferencedTarget sourceToTarget( ReferencedSource source ) { + ReferencedTarget target = new ReferencedTarget(); + target.setFoo( source.getFoo() ); + return target; + } +}