Skip to content

@InheritInverseConfiguration cannot directly inherit from prototype methods #1065

@sjaakd

Description

@sjaakd

I have the simple use case:

  1. SharedConfig
  2. Reuse SharedConfig to separate from-to, to-from into 2 separate classes, define the mappings once.

It does not work..

Applied to our unit test: org.mapstruct.ap.test.inheritfromconfig.InheritFromConfigTest, this is the reproducer:

@Mapper(
    uses = NotToBeUsedMapper.class,
    config = AutoInheritedConfig.class,
    mappingInheritanceStrategy = MappingInheritanceStrategy.EXPLICIT
)
public abstract class CarMapperReverseWithExplicitInheritance {
    public static final CarMapperReverseWithExplicitInheritance INSTANCE =
        Mappers.getMapper( CarMapperReverseWithExplicitInheritance.class );

    @InheritInverseConfiguration(name = "baseDtoToEntity")
    public abstract CarDto toCarDto(CarEntity entity);

}

Note: a similar method is there in CarMapperWithExplicitInheritance, but there the reverse mapping runs via a local present method.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions