Inverse Inheritance Strategy not working for ignored mappings only with target
Expected behavior
Inverse Configuration is autmatically generated.
Actual behavior
@Mappings have to be defined twice
Steps to reproduce the problem
Setup
@Mapper(config = FooBarConfig.class) public interface FooBarMapper { Bar toBar(Foo foo); Foo toFoo(Bar bar); } @Data class Foo { int secret; } @Data class Bar { int secret; } @MapperConfig(mappingInheritanceStrategy = MappingInheritanceStrategy.AUTO_INHERIT_ALL_FROM_CONFIG) interface FooBarConfig { @Mapping(target = "secret", ignore = true) Bar toBar(Foo foo); @InheritInverseConfiguration(name = "toBar") Foo toFoo(Bar bar); }
Generated
public class FooBarMapperImpl implements FooBarMapper { @Override public Bar toBar(Foo foo) { if ( foo == null ) { return null; } Bar bar = new Bar(); return bar; } @Override public Foo toFoo(Bar bar) { if ( bar == null ) { return null; } Foo foo = new Foo(); foo.setSecret( bar.getSecret() ); return foo; } }
Only way to get it working
@MapperConfig(mappingInheritanceStrategy = MappingInheritanceStrategy.AUTO_INHERIT_FROM_CONFIG) interface FooBarConfig { @Mapping(target = "secret", ignore = true) Bar toBar(Foo foo); @Mapping(target = "secret", ignore = true) Foo toFoo(Bar bar); }
MapStruct Version
1.5.5