mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2797: Add the nested type import types in the NestedPropertyMappingMethod
* #2797: Reproduction scenario * Add the nested type import types in the NestedPropertyMappingMethod Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com> Co-authored-by: Filip Hrisafov <filip.hrisafov@gmail.com>
This commit is contained in:
parent
07eeea6bc9
commit
2473c3eaaa
@ -103,7 +103,7 @@ public class NestedPropertyMappingMethod extends MappingMethod {
|
||||
public Set<Type> getImportTypes() {
|
||||
Set<Type> types = super.getImportTypes();
|
||||
for ( SafePropertyEntry propertyEntry : safePropertyEntries) {
|
||||
types.add( propertyEntry.getType() );
|
||||
types.addAll( propertyEntry.getType().getImportTypes() );
|
||||
if ( propertyEntry.getPresenceChecker() != null ) {
|
||||
types.addAll( propertyEntry.getPresenceChecker().getImportTypes() );
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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._2797;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
public class ExampleDto {
|
||||
|
||||
private String personFirstName;
|
||||
private String personLastName;
|
||||
|
||||
public String getPersonFirstName() {
|
||||
return personFirstName;
|
||||
}
|
||||
|
||||
public String getPersonLastName() {
|
||||
return personLastName;
|
||||
}
|
||||
|
||||
public void setPersonFirstName(String personFirstName) {
|
||||
this.personFirstName = personFirstName;
|
||||
}
|
||||
|
||||
public void setPersonLastName(String personLastName) {
|
||||
this.personLastName = personLastName;
|
||||
}
|
||||
}
|
@ -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._2797;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ap.test.bugs._2797.model.Example.Person;
|
||||
|
||||
import static org.mapstruct.ReportingPolicy.ERROR;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@Mapper(unmappedTargetPolicy = ERROR)
|
||||
public interface ExampleMapper {
|
||||
|
||||
@Mapping(target = "personFirstName", source = "names.first")
|
||||
@Mapping(target = "personLastName", source = "names.last")
|
||||
ExampleDto map(Person person);
|
||||
}
|
@ -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._2797;
|
||||
|
||||
import org.mapstruct.ap.test.bugs._2797.model.BasePerson;
|
||||
import org.mapstruct.ap.test.bugs._2797.model.Example;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@IssueKey( "2797" )
|
||||
@WithClasses( { ExampleDto.class, ExampleMapper.class, Example.class, BasePerson.class } )
|
||||
public class Issue2797Test {
|
||||
|
||||
@ProcessorTest
|
||||
void shouldCompile() {
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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._2797.model;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
public class BasePerson {
|
||||
|
||||
private Names names;
|
||||
|
||||
public Names getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
public void setNames(Names names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public static class Names {
|
||||
|
||||
private String first;
|
||||
private String last;
|
||||
|
||||
public String getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public String getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public void setFirst(String first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public void setLast(String last) {
|
||||
this.last = last;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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._2797.model;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
public class Example {
|
||||
|
||||
public static class Person extends BasePerson {
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user