mapstruct / mapstruct/mapstruct
Mapstruct doesn't use custom enum mapper
Open
Nobody has claimed this yet.
bug
- Dominant language
- Java
- Stars
- 7.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Expected behavior
public interface CarMapper {
CarDto carToCarDto(Car car);
CarDtoEnum from(CarEnum carEnum);
}
should generate something like:
public class CarMapperImpl implements CarMapper {
@Override
public CarDto carToCarDto(Car car) {
...
carDto.setCarDtoEnum(from(car.getCarEnum()));
}
}
Actual behavior
public class CarMapperImpl implements CarMapper {
@Override
public CarDto carToCarDto(Car car) {
...
carDto.setCarDtoEnum(Enum.valueOf(CarDtoEnum.class, car.getCarEnum()));
}
}
Steps to reproduce the problem
see above description.
MapStruct Version
1.5.2.Final
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the CarMapper, Car, CarDto, CarEnum, and CarDtoEnum types shown in the report, then inspect the generated CarMapperImpl. Trace why enum mapping selects Enum.valueOf instead of the declared from(CarEnum) method; done when the generated mapper invokes that custom method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100