Reputation: 201
I have a service that returns a Mono. In my controller, when I get the Mono, I would like to modify the A to another object B and return B.
How can I do this?
Upvotes: 1
Views: 1768
Reputation: 1739
Mono.map() function can be used for modifying the item emitted by the Mono.
Example:
Mono<A> aMono = Mono.just(new A());
Mono<B> bMono = aMono.map(a -> {
B b = new B();
b.setS(a.getS());
return b;
});
Upvotes: 2