`@Default` on Java Record's constructor isn't respected
Expected behavior
Record's constructor having @Default is called in the generated code.
Actual behavior
Record's constructor having @Default isn't called in the generated code.
The generated code is below.
class TaskMapperImpl implements TaskMapper { @Override public Task from(TaskDto testDbRecord) { if ( testDbRecord == null ) { return null; } String id = null; Long number = null; id = testDbRecord.id(); number = testDbRecord.number(); Task task = new Task( id, number ); return task; } }
Steps to reproduce the problem
- Configure the maven compiler plugin with the settings below (it's taken from docs)
mvn clean compilefor the below code snippets
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> <configuration> <release>19</release> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>1.5.3.Final</version> </path> </annotationProcessorPaths> </configuration> </plugin>
record Task(String id, Long number) { @Default Task(String id) { this(id, 1L); } }
record TaskDto(String id, Long number) { }
@Mapper interface TaskMapper { Task from(TaskDto testDbRecord); }
MapStruct Version
1.5.3.Final