简体   繁体   中英

How do I compare the values in 'Mono'?

Comparing the values in Mono<Integer> a and Mono<Integer> b , if the value in Mono<Integer> a is larger, I want to throw an error.

Mono<Integer> a = getA();
Mono<integer> b = getB();

if(a > b) {
 throw new RuntimeException();
}
Mono<Integer> a = Mono.just(12);
Mono<Integer> b = Mono.just(10);

a.zipWith(b)
    .doOnNext(tuple -> {
        if (tuple.getT1() > tuple.getT2()) {
            throw new RuntimeException();
        }
    }).subscribe();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM