In my reactive Java 9 Spring Boot 2 with Spring HATEOAS application, I have a REST API returning Mono<Resources<Resource<T>>>
. In the application layer, I'd like the data to be Mono<List<T>>
but how can I concisely map Mono<Resources<Resource<T>>>
to Mono<List<T>>
?
I was expecting something like:
public Mono<List<Order>> orders() {
return rest.orders()
.flatmap(List::stream)
.map(r -> r.getContent())
.collect(Collectors.toList());
}
but this fails to compile because List
does not define List.stream(Resources<Resource<Order>>
. The rest.orders()
returns Mono<Resources<Resource<Order>>>
. Any ideas?