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 compile for 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
Expected behavior
Record's constructor having
@Defaultis called in the generated code.Actual behavior
Record's constructor having
@Defaultisn't called in the generated code.The generated code is below.
Steps to reproduce the problem
mvn clean compilefor the below code snippetsMapStruct Version
1.5.3.Final