I have a class with the following Lombok annotations.
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class classA {
private String id;
private String a;
private String b;
}
I need to add a mapping to update an existing instance of ClassA as following :
@Mapping(target = "id", ignore = true)
ClassA update(ClassA oldA, @MappingTarget ClassA newA);
The generated mapper is the following, fields gets ignored in the generated mapping, because they don't have setters.
@Override
public Main.ClassA update(Main.ClassA oldA, Main.ClassA newA) {
if ( oldA == null ) {
return newA;
}
return newA;
}
I tried to use @BeanMapping(builder = @Builder(buildMethod = "toBuilder"))
but it has no effect
My goal is to make MapStruct use the toBuilder at the first and then the build method to return back a ClassA object, any tips to make this happen?