本文整理了Java中cyclops.reactive.ReactiveSeq.onEmptySwitch
方法的一些代码示例,展示了ReactiveSeq.onEmptySwitch
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.onEmptySwitch
方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:onEmptySwitch
暂无
代码示例来源:origin: aol/cyclops
static <T> Semigroup<ReactiveSeq<T>> firstNonEmptyReactiveSeq() {
return (a, b) -> a.onEmptySwitch(()->b);
}
static <T> Semigroup<ReactiveSeq<T>> ambReactiveSeq() {
代码示例来源:origin: aol/cyclops
/** If this Streamable is empty one it with a another Stream
*
* <pre>
* {@code
* assertThat(Streamable.of(4,5,6)
.onEmptySwitch(()->Streamable.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
* }
* </pre>
* @param switchTo Supplier that will generate the alternative Stream
* @return Streamable that will switch to an alternative Stream if empty
*/
default Streamable<T> onEmptySwitch(final Supplier<Streamable<T>> switchTo) {
return fromStream(this.stream().onEmptySwitch(() -> switchTo.get().stream()));
}
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(Spouts.of()
.onEmptySwitch(()->Spouts.of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(of()
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitch(){
assertThat(of(4,5,6)
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
}
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitch(){
assertThat(ReactiveSeq.of(4,5,6)
.onEmptySwitch(()->ReactiveSeq.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
}
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitch(){
assertThat(Spouts.of(4,5,6)
.onEmptySwitch(()->Spouts.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
}
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(of()
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(ReactiveSeq.of()
.onEmptySwitch(()->ReactiveSeq.of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
for(int i=0;i<1000;i++) {
assertThat(of()
.onEmptySwitch(() -> of(1, 2, 3))
.toList(),
equalTo(Arrays.asList(1, 2, 3)));
}
}
private int sleep(Integer i) {
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitch(){
assertThat(Spouts.of(4,5,6)
.onEmptySwitch(()->Spouts.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
}
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(of()
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(of()
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
private int sleep(Integer i) {
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(of()
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
private int sleep(Integer i) {
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
assertThat(Spouts.of()
.onEmptySwitch(()->Spouts.of(1,2,3))
.toList(),
equalTo(Arrays.asList(1,2,3)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitchEmpty(){
for(int i=0;i<1000;i++) {
assertThat(of()
.onEmptySwitch(() -> of(1, 2, 3))
.toList(),
equalTo(Arrays.asList(1, 2, 3)));
}
}
private int sleep(Integer i) {
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitch(){
assertThat(of(4,5,6)
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
}
代码示例来源:origin: aol/cyclops
@Test
public void onEmptySwitch(){
assertThat(of(4,5,6)
.onEmptySwitch(()->of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
}
代码示例来源:origin: com.oath.cyclops/cyclops
static <T> Semigroup<ReactiveSeq<T>> firstNonEmptyReactiveSeq() {
return (a, b) -> a.onEmptySwitch(()->b);
}
static <T> Semigroup<ReactiveSeq<T>> ambReactiveSeq() {
代码示例来源:origin: com.oath.cyclops/cyclops-pure
@Override
public <T> Higher<reactiveSeq, T> apply(Higher<reactiveSeq, T> a, Higher<reactiveSeq, T> b) {
return ReactiveSeq.narrowK(a).onEmptySwitch(()->ReactiveSeq.narrowK(b));
}
};
内容来源于网络,如有侵权,请联系作者删除!