Home Map Mono<Resources<Resource<T>>> to Mono<List<T>>?
Reply: 0

Map Mono<Resources<Resource<T>>> to Mono<List<T>>?

user899 Published in May 20, 2018, 10:13 am

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()
        .map(r -> r.getContent())

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.392777 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO