Skip to content

Mapping List in Record causes warning #2554

Description

@snystedt

Given the following classes/records and mappers

/* Car.java */
public class Car {
    private List<WheelPosition> wheelPositions;
    
    // constructors, getters, setters etc
/* CarDto.java */
public record CarDto(List<String> wheelPositions) {}
/* CarAndWheelMapper.java */
@Mapper
public interface CarAndWheelMapper {
    String stringFromWheelPosition(WheelPosition source);
    
    WheelPosition wheelPositionFromString(String source);
    
    CarDto carDtoFromCar(Car source);
    
    Car carFromCarDto(CarDto source);
}

Generates the following error:

<PATH>/CarAndWheelMapper.java:<LINE>: warning: Unmapped target properties: "elPositions".
    CarDto carDtoFromCar(Car source);

But the generated Impl is correct:

/* CarAndWheelMapperJavaImpl.java */
@Override
public CarDto carDtoFromCar(Car source) {
    if ( source  == null ) {
        return null;
    }
    
    wheelPositions = wheelPositionListToStringList( source.getWheelPositions() );
    
    CarDto carDto = new CarDto( wheelPositions );
    
    return carDto;
}

If I change the CarDto from a record to a class with an all argument constructor and getters the warning disappears.

Java version:

openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions