reactor.core.publisher.Flux.hasElement()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中reactor.core.publisher.Flux.hasElement()方法的一些代码示例,展示了Flux.hasElement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flux.hasElement()方法的具体详情如下:
包路径:reactor.core.publisher.Flux
类名称:Flux
方法名:hasElement

Flux.hasElement介绍

[英]Emit a single boolean true if any of the elements of this Flux sequence is equal to the provided value.

The implementation uses short-circuit logic and completes with true if an element matches the value.
[中]

代码示例

代码示例来源:origin: org.springframework.security/spring-security-core

@Override
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, T object) {
  return authentication
    .filter(a -> a.isAuthenticated())
    .flatMapIterable( a -> a.getAuthorities())
    .map( g-> g.getAuthority())
    .hasElement(this.authority)
    .map( hasAuthority -> new AuthorizationDecision(hasAuthority))
    .defaultIfEmpty(new AuthorizationDecision(false));
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = NullPointerException.class)
public void elementNull() {
  Flux.never().hasElement(null);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void normal2() {
  StepVerifier.create(Flux.range(1, 10).hasElement(4))
        .expectNext(true)
        .verifyComplete();
}
@Test

代码示例来源:origin: reactor/reactor-core

@Test
public void error2() {
  StepVerifier.create(Flux.range(1, 10).hasElement(-4))
        .expectNext(false)
        .verifyComplete();
}

代码示例来源:origin: com.aol.cyclops/cyclops-reactor

/**
 * @param value
 * @return
 * @see reactor.core.publisher.Flux#hasElement(java.lang.Object)
 */
public final Mono<Boolean> hasElement(T value) {
  return boxed.hasElement(value);
}
/**

代码示例来源:origin: apache/servicemix-bundles

@Override
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, T object) {
  return authentication
    .filter(a -> a.isAuthenticated())
    .flatMapIterable( a -> a.getAuthorities())
    .map( g-> g.getAuthority())
    .hasElement(this.authority)
    .map( hasAuthority -> new AuthorizationDecision(hasAuthority))
    .defaultIfEmpty(new AuthorizationDecision(false));
}

相关文章

微信公众号

最新文章

更多

Flux类方法