mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#206 adding case for protected method in same package
This commit is contained in:
parent
e144519b28
commit
a77a693d9d
@ -240,11 +240,12 @@ public class MethodRetrievalProcessor implements ModelElementProcessor<Void, Lis
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ( method.getModifiers().contains( Modifier.PROTECTED ) ) {
|
else if ( method.getModifiers().contains( Modifier.PROTECTED ) ) {
|
||||||
return mapperToImplement.isAssignableTo( usedMapper );
|
return mapperToImplement.isAssignableTo( usedMapper ) ||
|
||||||
|
mapperToImplement.getPackageName().equals( usedMapper.getPackageName() );
|
||||||
}
|
}
|
||||||
else if ( !method.getModifiers().contains( Modifier.PUBLIC ) ) {
|
else if ( !method.getModifiers().contains( Modifier.PUBLIC ) ) {
|
||||||
// default
|
// default
|
||||||
return mapperToImplement.getPackageName().equals( usedMapper.getPackageName());
|
return mapperToImplement.getPackageName().equals( usedMapper.getPackageName() );
|
||||||
}
|
}
|
||||||
// public
|
// public
|
||||||
return true;
|
return true;
|
||||||
|
@ -58,6 +58,11 @@ public class ReferencedAccessibilityTest {
|
|||||||
@WithClasses( { SourceTargetMapperDefaultSame.class, ReferencedMapperDefaultSame.class } )
|
@WithClasses( { SourceTargetMapperDefaultSame.class, ReferencedMapperDefaultSame.class } )
|
||||||
public void shouldBeAbleToAccessDefaultMethodInReferencedInSamePackage() throws Exception { }
|
public void shouldBeAbleToAccessDefaultMethodInReferencedInSamePackage() throws Exception { }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@IssueKey( "206" )
|
||||||
|
@WithClasses( { SourceTargetMapperProtected.class, ReferencedMapperProtected.class } )
|
||||||
|
public void shouldBeAbleToAccessProtectedMethodInReferencedInSamePackage() throws Exception { }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@IssueKey( "206" )
|
@IssueKey( "206" )
|
||||||
@WithClasses( { SourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } )
|
@WithClasses( { SourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } )
|
||||||
|
@ -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 ReferencedMapperProtected {
|
||||||
|
|
||||||
|
protected ReferencedTarget sourceToTarget( ReferencedSource source ) {
|
||||||
|
ReferencedTarget target = new ReferencedTarget();
|
||||||
|
target.setFoo( source.getFoo() );
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
@ -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 = ReferencedMapperProtected.class)
|
||||||
|
public interface SourceTargetMapperProtected {
|
||||||
|
|
||||||
|
SourceTargetMapperProtected INSTANCE = Mappers.getMapper( SourceTargetMapperProtected.class );
|
||||||
|
|
||||||
|
@Mapping(source = "referencedSource", target = "referencedTarget")
|
||||||
|
Target toTarget(Source source);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user