Expected behavior
Given a mapping method which takes a single argument of primitive long, like below:
import org.junit.jupiter.api.*;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import static org.assertj.core.api.Assertions.assertThat;
class PrimitiveMapperTest {
@Test
@DisplayName("should convert primitive type")
void shouldConvertPrimitiveType() {
var mapper = Mappers.getMapper(PrimitiveMapper.class);
var target = mapper.map(123);
assertThat(target.value()).isEqualTo(123);
}
protected record Target(long value) {}
}
@Mapper
abstract class PrimitiveMapper {
@Mapping(target = "value", source = "value")
public abstract PrimitiveMapperTest.Target map(long value);
}
An expectation is that the mapping method is generated and the test passes.
(Mapstruct is configured with -Amapstruct.unmappedTargetPolicy=ERROR)
Actual behavior
Compilation fails with a message:
java: Can't generate mapping method with primitive parameter type.
Funny enough, it starts working after adding a 2nd argument which could also be of a primitive (sic!) type. I could make the above example working like this:
...
public abstract PrimitiveMapperTest.Target map(long value, long unused);
Steps to reproduce the problem
See above
MapStruct Version
1.6.3
Expected behavior
Given a mapping method which takes a single argument of primitive
long, like below:An expectation is that the mapping method is generated and the test passes.
(Mapstruct is configured with
-Amapstruct.unmappedTargetPolicy=ERROR)Actual behavior
Compilation fails with a message:
Funny enough, it starts working after adding a 2nd argument which could also be of a primitive (sic!) type. I could make the above example working like this:
... public abstract PrimitiveMapperTest.Target map(long value, long unused);Steps to reproduce the problem
See above
MapStruct Version
1.6.3