mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
(cherry picked from commit ade4f4d7e2ab87b2e0f113221d3fc9a6729f78cc)
This commit is contained in:
parent
b32cf92519
commit
0c1c5b7f31
@ -44,7 +44,7 @@ public class BeanMapping {
|
|||||||
*/
|
*/
|
||||||
public static BeanMapping forInheritance( BeanMapping map ) {
|
public static BeanMapping forInheritance( BeanMapping map ) {
|
||||||
return new BeanMapping(
|
return new BeanMapping(
|
||||||
map.selectionParameters,
|
SelectionParameters.forInheritance( map.selectionParameters ),
|
||||||
map.nullValueMappingStrategy,
|
map.nullValueMappingStrategy,
|
||||||
map.nullValuePropertyMappingStrategy,
|
map.nullValuePropertyMappingStrategy,
|
||||||
map.nullValueCheckStrategy,
|
map.nullValueCheckStrategy,
|
||||||
|
@ -26,6 +26,23 @@ public class SelectionParameters {
|
|||||||
private final Types typeUtils;
|
private final Types typeUtils;
|
||||||
private final SourceRHS sourceRHS;
|
private final SourceRHS sourceRHS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns new selection parameters
|
||||||
|
*
|
||||||
|
* ResultType is not inherited.
|
||||||
|
*
|
||||||
|
* @param selectionParameters
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static SelectionParameters forInheritance(SelectionParameters selectionParameters) {
|
||||||
|
return new SelectionParameters(
|
||||||
|
selectionParameters.qualifiers,
|
||||||
|
selectionParameters.qualifyingNames,
|
||||||
|
null,
|
||||||
|
selectionParameters.typeUtils
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public SelectionParameters(List<TypeMirror> qualifiers, List<String> qualifyingNames, TypeMirror resultType,
|
public SelectionParameters(List<TypeMirror> qualifiers, List<String> qualifyingNames, TypeMirror resultType,
|
||||||
Types typeUtils) {
|
Types typeUtils) {
|
||||||
this( qualifiers, qualifyingNames, resultType, typeUtils, null );
|
this( qualifiers, qualifyingNames, resultType, typeUtils, null );
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._1821;
|
||||||
|
|
||||||
|
import org.mapstruct.BeanMapping;
|
||||||
|
import org.mapstruct.InheritConfiguration;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface Issue1821Mapper {
|
||||||
|
|
||||||
|
Issue1821Mapper INSTANCE = Mappers.getMapper( Issue1821Mapper.class );
|
||||||
|
|
||||||
|
@BeanMapping( resultType = Target.class )
|
||||||
|
Target map(Source source);
|
||||||
|
|
||||||
|
@InheritConfiguration( name = "map" )
|
||||||
|
ExtendedTarget mapExtended(Source source);
|
||||||
|
|
||||||
|
class Target {
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExtendedTarget extends Target {
|
||||||
|
}
|
||||||
|
|
||||||
|
class Source {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._1821;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
|
||||||
|
@IssueKey("1797")
|
||||||
|
@RunWith( AnnotationProcessorTestRunner.class)
|
||||||
|
@WithClasses( Issue1821Mapper.class )
|
||||||
|
public class Issue1821Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldNotGiveNullPtr() {
|
||||||
|
Issue1821Mapper.INSTANCE.map( new Issue1821Mapper.Source() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user