本文整理了Java中cyclops.reactive.ReactiveSeq.firstValue
方法的一些代码示例,展示了ReactiveSeq.firstValue
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.firstValue
方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:firstValue
[英]```
assertThat(ReactiveSeq.of(1,2,3,4).map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
}
[中]```
assertThat(ReactiveSeq.of(1,2,3,4).map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
public static final <T> Function1<? super Iterable<T>,? extends T> tail(){
return it -> ReactiveSeq.fromIterable(it)
.takeRight(1)
.firstValue(null);
}
public static final <T> Function1<? super Iterable<T>,? extends T> reduce(Monoid<T> monoid){
代码示例来源:origin: aol/cyclops
@Test
public void recover(){
assertThat(of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recover(){
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recover(){
assertThat(of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recoverIO(){
assertThat(Spouts.of(1,2,3,4)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recover2(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void recoverIO(){
assertThat(of(1,2,3,4)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recover2(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void recover2(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void recover2(){
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void recoverIO(){
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{
ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recoverIO(){
assertThat(of(1,2,3,4)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test
public void recover3(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.map(i->"x!"+i)
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void recover2IO(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(IOException.class,e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test(expected=IOException.class)
代码示例来源:origin: aol/cyclops
@Test
public void retryShouldNotThrowNPEIfRetryIsZero() {
Function<Integer, Integer> fn = i -> 2 * i;
int result = of(1)
.retry(fn, 0, 1, TimeUnit.SECONDS)
.firstValue(null);
assertEquals(2, result);
}
代码示例来源:origin: aol/cyclops
@Test
public void recover2IO(){
assertThat(Spouts.of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(IOException.class,e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test(expected=IOException.class)
代码示例来源:origin: aol/cyclops
@Test
public void recover3(){
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.map(i->"x!"+i)
.recover(e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void recover2IO(){
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(IOException.class,e->"hello")
.firstValue(null),equalTo("hello"));
}
@Test(expected=IOException.class)
代码示例来源:origin: aol/cyclops
@Test(expected=IOException.class)
public void recoverIOUnhandledThrown(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.map(i->"x!"+i)
.recover(IllegalStateException.class,e->"hello")
.firstValue(null),equalTo("hello"));
}
代码示例来源:origin: aol/cyclops
@Test(expected=IOException.class)
public void recoverIOUnhandledThrown(){
assertThat(of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.map(i->"x!"+i)
.recover(IllegalStateException.class,e->"hello")
.firstValue(null),equalTo("hello"));
}
内容来源于网络,如有侵权,请联系作者删除!