I have these 3 classes in separate files
public class Book {
@Id
@GeneratedValue
private Long id;
@NonNull
private String title;
@NonNull
private Author author;
}
public class Author {
@Id
@GeneratedValue
private Long id;
@NonNull
private String firstName;
@NonNull
private String lastName;
}
public class BookDTO {
private Long id;
@NonNull
private String title;
@NonNull
private String author;
}
I have the following mapper
@Mapper
public interface BookMapper {
BookMapper INSTANCE = Mappers.getMapper(BookMapper.class);
@Mappings({
@Mapping(source = "author.lastName", target = "author")
})
BookDTO toDTO(Book book);
}
this currently only maps the lastName and works, and I want to map the author string in Book with
author.firstName + " " + author.lastName
how could I do that? I have not been able to find anything in the MapStruct Documentation.