mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#3248 BeanMapping#ignoreUnmappedSourceProperties should be inherited for @InheritConfiguration
This commit is contained in:
parent
b1034e6703
commit
d10d48ccff
@ -41,13 +41,14 @@ public class BeanMappingOptions extends DelegatingOptions {
|
||||
* creates a mapping for inheritance. Will set
|
||||
*
|
||||
* @param beanMapping the bean mapping options that should be used
|
||||
* @param isInverse whether the inheritance is inverse
|
||||
*
|
||||
* @return new mapping
|
||||
*/
|
||||
public static BeanMappingOptions forInheritance(BeanMappingOptions beanMapping) {
|
||||
public static BeanMappingOptions forInheritance(BeanMappingOptions beanMapping, boolean isInverse) {
|
||||
BeanMappingOptions options = new BeanMappingOptions(
|
||||
SelectionParameters.forInheritance( beanMapping.selectionParameters ),
|
||||
Collections.emptyList(),
|
||||
isInverse ? Collections.emptyList() : beanMapping.ignoreUnmappedSourceProperties,
|
||||
beanMapping.beanMapping,
|
||||
beanMapping
|
||||
);
|
||||
|
@ -167,7 +167,7 @@ public class MappingMethodOptions {
|
||||
}
|
||||
|
||||
if ( !getBeanMapping().hasAnnotation() && templateOptions.getBeanMapping().hasAnnotation() ) {
|
||||
setBeanMapping( BeanMappingOptions.forInheritance( templateOptions.getBeanMapping( ) ) );
|
||||
setBeanMapping( BeanMappingOptions.forInheritance( templateOptions.getBeanMapping( ), isInverse ) );
|
||||
}
|
||||
|
||||
if ( !getEnumMappingOptions().hasAnnotation() && templateOptions.getEnumMappingOptions().hasAnnotation() ) {
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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._3248;
|
||||
|
||||
import org.mapstruct.BeanMapping;
|
||||
import org.mapstruct.InheritConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@Mapper(unmappedSourcePolicy = ReportingPolicy.ERROR)
|
||||
public interface Issue3248Mapper {
|
||||
|
||||
@BeanMapping(ignoreUnmappedSourceProperties = "otherValue")
|
||||
Target map(Source source);
|
||||
|
||||
@InheritConfiguration
|
||||
Target secondMap(Source source);
|
||||
|
||||
class Target {
|
||||
private final String value;
|
||||
|
||||
public Target(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
class Source {
|
||||
private final String value;
|
||||
|
||||
public Source(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getOtherValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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._3248;
|
||||
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@IssueKey("3248")
|
||||
@WithClasses({
|
||||
Issue3248Mapper.class
|
||||
})
|
||||
class Issue3248Test {
|
||||
|
||||
@ProcessorTest
|
||||
void shouldCompileCode() {
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user