I have the following classes and mapper to map them. How can I configure Mapstruct to "not" use the Lombok builder? (without removing the @Builder annotation)? When using the latest version of Lombok and mapstruct, mapstruct will automatically use the Builder when the @Builder annotation is used. I can not find a way to disable that, as I need the Instance in an @AfterMapping method as the builder doesn't expose all required methods (@SuperBuilder is not allowed in this use case)
@Entity(name = "user_details")
@Data
@Builder
public class User extends AuditableEntityBase {
@Version
@NotNull
private Integer version;
@NotNull
private String name;
@NotNull
private String email;
@NotNull
private Address address; // Just another Class containing another class that is mapped as well.
}
@Value
@Builder
public class UserDto extends AuditableEntityBaseDto {
@NotNull
private Integer version;
@NotNull
private String name;
@NotNull
private String email;
@NotNull
private AddressDto address;
}
@Mapper(componentModel = "spring")
class UserRestMapper {
public abstract UserDto map(User obj);
}
@AfterMapping
public void decorate(User source, @MappingTarget AuditableEntityBase target) {
// Method is never called.
// Method is called in case the second argument is: "@MappingTarget UserDto.UserDtoBuilder target"
}