简体   繁体   English

如何比较“单声道”中的值?

[英]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> aMono<Integer> b中的值,如果Mono<Integer> a中的值更大,我想抛出一个错误。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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