本文整理了Java中cyclops.reactive.ReactiveSeq.findFirstOrError
方法的一些代码示例,展示了ReactiveSeq.findFirstOrError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.findFirstOrError
方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:findFirstOrError
[英]Lazy / reactive look up of first value , capturing the first error, if one occurs. If no values are present a NoSuchElementException is returned. For push based reactive-streams (created via Spouts.XXX) data will be pushed to the returned Either on arrival. For pull based Streams (created via ReactiveSeq.XXX) the Stream will be executed when the Either is first accessed.
[中]惰性/被动查找第一个值,如果出现第一个错误,则捕获第一个错误。如果不存在任何值,则返回NoTouchElementException。对于基于推送的反应流(通过Spouts.XXX创建),数据将在到达时推送到返回的服务器。对于基于pull的流(通过ReactiveSeq.XXX创建),当第一次访问其中一个时,将执行该流。
代码示例来源:origin: aol/cyclops
@Test
public void combineOneFirstOrError() {
assertThat(of(1)
.combine((a, b) -> a < 5, Semigroups.intSum)
.findFirstOrError(), Matchers.equalTo(LazyEither.right(1)));
}
代码示例来源:origin: aol/cyclops
@Test
public void combineOneFirstOrError() {
assertThat(ofWait(1)
.combine((a, b) -> a < 5, Semigroups.intSum)
.findFirstOrError(), Matchers.equalTo(LazyEither.right(1)));
}
@Test
代码示例来源:origin: aol/cyclops
private Either<Error,Vector<String>> loadContents(Vector<DataFileMetadata> files){
/**
return Spouts.from(Flux.from(files.stream())
.flatMap(file->asyncWithRetry(1,file,exec),10))
.reduceAll(Vector.<String>empty(), Vector::appendAll)
.findFirstOrError()
.mapLeft(t-> Error.LOADING_FAILED);
**/
return files.stream()
.mergeMap(10,file->asyncWithRetry(1,file,exec))
.reduceAll(Vector.<String>empty(), Vector::appendAll)
.findFirstOrError()
.mapLeft(t-> Error.LOADING_FAILED);
}
}
代码示例来源:origin: com.oath.cyclops/cyclops-futurestream
@Override
default LazyEither<Throwable, U> findFirstOrError(){
return stream().findFirstOrError();
}
内容来源于网络,如有侵权,请联系作者删除!