-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
When upgrading from Mapstruct 1.4.2 to 1.5.0.RC1 I get Ambiguous mapping methods error.
Given the following MappingConfiguration I want to make use of the support of the new Jakarta annotations.
@MapperConfig(
componentModel = "jakarta",
unmappedTargetPolicy = ReportingPolicy.ERROR,
injectionStrategy = InjectionStrategy.CONSTRUCTOR,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public class MicronautMappingConfig {}The following mapper maps Short and Integer to their primitive value which used to work in Mapstruct 1.4.2
@Mapper(config = MicronautMappingConfig.class)
public interface NumberousMapper {
NumberDto toNumberDto(Short shortValue, Integer intValue);
default int toInt(Number number) {
return number.intValue();
}
default short toShort(Number number) {
return number.shortValue();
}
}
class NumberDto {
private int intValue;
private short shortValue;
public int getIntValue() {
return intValue;
}
public void setIntValue(int intValue) {
this.intValue = intValue;
}
public short getShortValue() {
return shortValue;
}
public void setShortValue(short shortValue) {
this.shortValue = shortValue;
}
}With Mapstruct 1.5.0.RC1 I get the following error
NumberousMapper.java:8: error: Ambiguous mapping methods found for mapping property "Integer intValue" to int: int toInt(Number number), short toShort(Number number). See https://mapstruct.org/faq/#ambiguous for more info.
NumberDto toNumberDto(Short shortValue, Integer intValue);
^