Skip to content

Improve Lombok integration documentation #3374

@Nikolas-Charalambidis

Description

@Nikolas-Charalambidis

Expected behavior

Assuming the following code and configuration below, I expect the compilation to succeed and the mapper to generate something like this:

public Foo.CarDto toDto(Foo.Car car) {
    if (car == null) {
        return null;
    } else {
        Foo.CarDto carDto = new Foo.CarDto();
        carDto.setEWhatever2(car.getEWhatever1());
        return carDto;
    }
}

Actual behavior

Compilation fails and no implementation is generated.

java: No property named "eWhatever1" exists in source parameter(s). Did you mean "EWhatever1"?

Steps to reproduce the problem

  • Java 17
  • MapStruct 1.5.3.Final
  • Lombok 1.18.22
  • Lombok Mapstruct Binding 0.2.0
@Mapper
public interface BadMapper {

    @Mapping(target = "eWhatever2", source = "eWhatever1")
    CarDto toDto(Car car);
}
@Data
public class Car {

    private String eWhatever1;
}
@Data
public class CarDto {

    private String eWhatever2;
}

It is important the 1st letter of the variable is lowercase and the 2nd one is uppercase.

  • Ewhatever interestingly produces a similar error.
  • eWhatever doesn't work.
  • ewHatever is ok.
  • ewhatever is ok.

MapStruct Version

MapStruct 1.5.3.Final

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions