mapstruct / mapstruct-idea

An IntelliJ IDEA plugin for working with MapStruct
Other
141 stars 38 forks source link

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

Open filiphr opened 7 months ago

filiphr commented 7 months ago

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.