mapstruct-idea icon indicating copy to clipboard operation
mapstruct-idea copied to clipboard

Wrong usage of mappers factory should be able to remove static initializer

Open filiphr opened this issue 1 year ago • 0 comments

Why reviewing PR #179 @hduelme pointed out that the Wrong usage of mappers factory does not work (i.e. it does not remove it) with the following code:

@Mapper(componentModel = "spring")
abstract class WrongComponentModelMapper {

    static {
        Mappers.getMapper(WrongComponentModelMapper.class);
    }
    
    Target map(Target source);
}

or

@Mapper(config = MyConfig.class, componentModel = "spring")
interface WrongComponentModelMapper {


    WrongComponentModelMapper INSTANCE = () -> {
        return Mappers.getMapper(WrongComponentModelMapper.class);
    };

    Target map(Target source);
}

We need to see if we can support this.

filiphr avatar Mar 16 '24 11:03 filiphr