My project uses MapStruct successfully when it does not include Flux or Flow streams. When I try to generate a mapper with a Flow or Flux, I receive an error: “error: The return type Flow is an abstract class or interface.” Since Flow and Flux are interfaces, is there a way to still use MapStruct or do I have to roll my own mapper in this use-case?
Thank you for your comments and time
Advertisement
Answer
I don’t know from what you want to create the Kotlin Flow or Reactor Flux. If it is from other Flow or Flux then you will have to do that partially manual
e.g.
@Mapper public interface CustomerMapper { default Flow<CustomerDto> map(Flow<Customer> customers) { return customers.map(this::map); } CustomerDto map(Customer customer); }
It would be similar for react as well. If you are interested in MapStruct supporting this out of the box I would suggest raising a feature request in the MapStruct issue tracker