cyclops.reactive.ReactiveSeq.ofType()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(121)

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

ReactiveSeq.ofType介绍

[英]Keep only those elements in a stream that are of a given type. // (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
[中]只保留流中给定类型的元素。//(1,2,3)反应性。(1,“a”,2,“b”,3)中的一个。类型(Integer.class)

代码示例

代码示例来源:origin: aol/cyclops

/**
 * Keep only those elements in a stream that are of a given type.
 *
 *
 * // (1, 2, 3) Streamable.of(1, "a", 2, "b",3).ofType(Integer.class)
 *
 */
@Override
@SuppressWarnings("unchecked")
default <U> Streamable<U> ofType(final Class<? extends U> type) {
  return fromStream(this.stream().ofType(type));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(Streams.ofType(Stream.of(1, "a", 2, "b", 3, null),Integer.class).collect(Collectors.toList()),containsInAnyOrder(1, 2, 3));
  assertThat(ReactiveSeq.of(1, "a", 2, "b", 3, null).ofType(Integer.class).collect(Collectors.toList()),not(containsInAnyOrder("a", "b",null)));
  assertThat(ReactiveSeq.of(1, "a", 2, "b", 3, null)
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(Spouts.of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),containsInAnyOrder(1, 2, 3));
  assertThat(Spouts.of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),not(containsInAnyOrder("a", "b",null)));
  assertThat(Spouts.of(1, "a", 2, "b", 3, null)
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(ReactiveSeq.of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),containsInAnyOrder(1, 2, 3));
  assertThat(ReactiveSeq.of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),not(containsInAnyOrder("a", "b",null)));
  assertThat(ReactiveSeq.of(1, "a", 2, "b", 3, null)
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(of(1, "a", 2, "b", 3, "c").ofType(Integer.class).toList(),containsInAnyOrder(1, 2, 3));
  assertThat(of(1, "a", 2, "b", 3,"c").ofType(Integer.class).toList(),not(containsInAnyOrder("a", "b","c")));
  assertThat(of(1, "a", 2, "b", 3, "c")
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3,"c"));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),containsInAnyOrder(1, 2, 3));
  assertThat(of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),not(containsInAnyOrder("a", "b",null)));
  assertThat(of(1, "a", 2, "b", 3, null)
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(Spouts.of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),containsInAnyOrder(1, 2, 3));
  assertThat(Spouts.of(1, "a", 2, "b", 3, null).ofType(Integer.class).toList(),not(containsInAnyOrder("a", "b",null)));
  assertThat(Spouts.of(1, "a", 2, "b", 3, null)
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3));
}

代码示例来源:origin: aol/cyclops

@Test
public void testOfType() {
  assertThat(of(1, "a", 2, "b", 3, "c").ofType(Integer.class).toList(),containsInAnyOrder(1, 2, 3));
  assertThat(of(1, "a", 2, "b", 3,"c").ofType(Integer.class).toList(),not(containsInAnyOrder("a", "b","c")));
  assertThat(of(1, "a", 2, "b", 3, "c")
      .ofType(Serializable.class).toList(),containsInAnyOrder(1, "a", 2, "b", 3,"c"));
}

代码示例来源:origin: com.oath.cyclops/cyclops

/**
 * Keep only those elements in a stream that are of a given type.
 *
 *
 * // (1, 2, 3) Streamable.of(1, "a", 2, "b",3).ofType(Integer.class)
 *
 */
@Override
@SuppressWarnings("unchecked")
default <U> Streamable<U> ofType(final Class<? extends U> type) {
  return fromStream(this.stream().ofType(type));
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法