mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
parent
082704cc55
commit
81a88bdb6c
@ -472,7 +472,10 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
||||
}
|
||||
|
||||
private Type getReturnTypeToConstructFromSelectionParameters(SelectionParameters selectionParams) {
|
||||
if ( selectionParams != null && selectionParams.getResultType() != null ) {
|
||||
// resultType only applies to method that actually has @BeanMapping annotation, never to forged methods
|
||||
if ( !( method instanceof ForgedMethod )
|
||||
&& selectionParams != null
|
||||
&& selectionParams.getResultType() != null ) {
|
||||
return ctx.getTypeFactory().getType( selectionParams.getResultType() );
|
||||
}
|
||||
return null;
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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._2133;
|
||||
|
||||
import org.mapstruct.BeanMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface Issue2133Mapper {
|
||||
|
||||
Issue2133Mapper INSTANCE = Mappers.getMapper( Issue2133Mapper.class );
|
||||
|
||||
@BeanMapping(resultType = Target.class)
|
||||
AbstractTarget map(Source source);
|
||||
|
||||
class Source {
|
||||
|
||||
private EmbeddedDto embedded;
|
||||
|
||||
public EmbeddedDto getEmbedded() {
|
||||
return embedded;
|
||||
}
|
||||
|
||||
public void setEmbedded(EmbeddedDto embedded) {
|
||||
this.embedded = embedded;
|
||||
}
|
||||
}
|
||||
|
||||
class Target extends AbstractTarget {
|
||||
}
|
||||
|
||||
abstract class AbstractTarget {
|
||||
|
||||
private EmbeddedEntity embedded;
|
||||
|
||||
public EmbeddedEntity getEmbedded() {
|
||||
return embedded;
|
||||
}
|
||||
|
||||
public void setEmbedded(EmbeddedEntity embedded) {
|
||||
this.embedded = embedded;
|
||||
}
|
||||
}
|
||||
|
||||
class EmbeddedDto {
|
||||
|
||||
private String s1;
|
||||
|
||||
public String getS1() {
|
||||
return s1;
|
||||
}
|
||||
|
||||
public void setS1(String s1) {
|
||||
this.s1 = s1;
|
||||
}
|
||||
}
|
||||
|
||||
class EmbeddedEntity {
|
||||
|
||||
private String s1;
|
||||
|
||||
public String getS1() {
|
||||
return s1;
|
||||
}
|
||||
|
||||
public void setS1(String s1) {
|
||||
this.s1 = s1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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._2133;
|
||||
|
||||
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("2133")
|
||||
@WithClasses( Issue2133Mapper.class )
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
public class Issue2133Test {
|
||||
|
||||
@Test
|
||||
public void shouldCompile() {
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user