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

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

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

ReactiveSeq.toList介绍

暂无

代码示例

代码示例来源:origin: aol/micro-server

private List<Class> buildClasses(Class class1, Microserver microserver) {
  List<Class> classes = new ArrayList();
  classes.add(class1);
  if (microserver.classes() != null)
    classes.addAll(Arrays.asList(microserver.classes()));
  List<Plugin> modules = PluginLoader.INSTANCE.plugins.get();
  if(modules.size()>0)
    classes.addAll(ReactiveSeq.fromStream(modules.stream()).flatMap(module -> module.springClasses().stream()).toList());
  
  return classes;
}

代码示例来源:origin: aol/micro-server

private ServerApplication createServer(Module module) {
  List<ServerApplicationFactory> applications = ReactiveSeq.fromStream(PluginLoader.INSTANCE.plugins.get()
                                                   .stream())
                               .filter(m -> m.serverApplicationFactory() != null)
                               .map(Plugin::serverApplicationFactory)
                               .flatMap(Streams::optionalToStream)
                               .toList();
  if (applications.size() > 1) {
    logger.error("ERROR!  Multiple server application factories found : The solution is remove one these plugins from your classpath ",
           applications);
    System.err.println("ERROR!  Multiple server application factories found : The solution is remove one these plugins from your classpath "
        + applications);
    throw new IncorrectNumberOfServersConfiguredException(
                               "Multiple server application factories found : The solution is remove one these plugins from your classpath "
                                   + applications);
  } else if (applications.size() == 0) {
    logger.error("ERROR!  No server application factories found. If you using micro-spring-boot don't call MicroserverApp.start() method. A possible solution is add one of micro-grizzly or micro-tomcat to the classpath.");
    System.err.println("ERROR!  No server application factories found. If you using micro-spring-boot don't call MicroserverApp.start() method. A possible solution is add one of micro-grizzly or micro-tomcat to the classpath.");
    throw new IncorrectNumberOfServersConfiguredException(
                               "No server application factories found. If you using micro-spring-boot don't call MicroserverApp.start() method. A possible solution is add one of micro-grizzly or micro-tomcat to the classpath. ");
  }
  ServerApplication app = applications.get(0)
                    .createApp(module, springContext);        
  return app;
}

代码示例来源:origin: aol/micro-server

default String getJaxWsRsApplication() {
  List<String> jaxRsApplications = ReactiveSeq.fromStream(PluginLoader.INSTANCE.plugins.get()
                                             .stream())
                        .filter(module -> module.jaxWsRsApplication() != null)
                        .map(Plugin::jaxWsRsApplication)
                        .flatMap(Streams::optionalToStream)
                        .toList();
  if (jaxRsApplications.size() > 1) {
    throw new IncorrectJaxRsPluginsException(
                         "ERROR!  Multiple jax-rs application plugins found,  a possible solution is to remove micro-jackson or other jax-rs application provider from your classpath. "
                             + jaxRsApplications);
  } else if (jaxRsApplications.size() == 0) {
    throw new IncorrectJaxRsPluginsException(
                         "ERROR!  No jax-rs application plugins found, a possible solution is to add micro-jackson to your classpath. ");
  }
  return jaxRsApplications.get(0);
}

代码示例来源:origin: aol/micro-server

@Test
public void testExtractResourceClassName(){
  
  assertThat(serverData.extractResources().toList().get(0)._1(),is(ServletStatusResource.class.getName()));
  
}
@Test

代码示例来源:origin: aol/micro-server

private List<SpringDBConfig> getConfig(Config config, AnnotationConfigWebApplicationContext rootContext,
    ConfigurableListableBeanFactory beanFactory) {
  List<SpringDBConfig> result = ReactiveSeq.fromStream(PluginLoader.INSTANCE.plugins.get()
                                           .stream())
                       .filter(module -> module.springDbConfigurer() != null)
                       .map(Plugin::springDbConfigurer)
                       .flatMap(Streams::optionalToStream)
                       .toList();
  result.forEach(next -> {
    next.setBeanFactory(beanFactory);
    next.setRootContext(rootContext);
    next.setConfig(config);
  });
  return result;
}

代码示例来源:origin: aol/micro-server

@Test
public void testExtractResourcePath(){
  
  
  assertThat(serverData.extractResources().toList().get(0)._2(),is("/servlet"));
  
}

代码示例来源:origin: aol/micro-server

.map(Plugin::restServletConfiguration)
                          .flatMap(Streams::optionalToStream)
                          .toList();
if (restConfigList.size() > 1) {
  throw new IncorrectJaxRsPluginsException(

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

@Test
public void mergeSimple(){
  for(int i=0;i<ITERATIONS;i++) {
    assertThat(Spouts.mergeLatest(nextAsync()).toList(), equalTo(Arrays.asList(1, 2)));
  }
}
@Test

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

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final Tuple2<Option<T>, ReactiveSeq<T>> splitAtHead() {
  final Tuple2<ReactiveSeq<T>, ReactiveSeq<T>> t2 = splitAt(1);
   return Tuple2.of(
    Option.fromIterable( t2._1().toList())
          ,
         t2._2());
}

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

@Test
public void flatMapP(){
  assertThat(Spouts.of(1,2,3)
      .mergeMap(i->Spouts.of(i))
      .toList(),equalTo(Arrays.asList(1,2,3)));
}
@Test

代码示例来源: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 subStream(){
  List<Integer> list = ReactiveSeq.of(1,2,3,4,5,6).subStream(1,3).toList();
  assertThat(list,equalTo(Arrays.asList(2,3)));
}
@Test

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

@Test
public void rangeIntSkip2(){
  assertThat(ReactiveSeq.range(0,5)
      .skip(3).toList(),equalTo(Arrays.asList(3,4)));
}

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

@Test @Ignore
public void shouldRethrowOriginalExceptionFromUserFutureCompletion()
    throws Exception {
  given(serviceMock.apply(anyInt())).willThrow(
      new RuntimeException("DONT PANIC"));
  List<String> result = ReactiveSeq.of(1)
      .retry(serviceMock).toList();
  assertThat(result.size(), is(0));
  assertThat((error).getMessage(), is("DONT PANIC"));
}

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

@Test
public void flatMapFlux(){
  for(int i=0;i<10000;i++){
    System.out.println("************Iteration " + i);
    Assert.assertThat(flux(1)
            .flatMap(in -> flux(1, 2, 3))
            .toList(),
        Matchers.equalTo(Arrays.asList(1, 2, 3)));
  }
}

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

@Test
  public void testScanRightSumMonoid() {
    assertThat(of("a", "ab", "abc").map(str -> str.length()).scanRight(Reducers.toTotalInt()).toList(), is(asList(0, 3, 5, 6)));

  }
}

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

@Test
public void rangeIntReversed(){
  assertThat(ReactiveSeq.range(0,Integer.MAX_VALUE).reverse()
      .limit(2).toList(),equalTo(Arrays.asList(2147483646, 2147483645)));
}
@Test

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

@Test
public void limitTimeEmpty(){
  List<Integer> result = ReactiveSeq.<Integer>of()
                  .peek(i->sleep(i*100))
                  .take(1000,TimeUnit.MILLISECONDS)
                  .toList();
  assertThat(result,equalTo(Arrays.asList()));
}
@Test

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

@Test
public void flatMapP2(){
  MatcherAssert.assertThat(Spouts.of(1,2,3)
      .mergeMap(i->Spouts.of(1,i))
      .toList(),Matchers.hasItems(1,1,1,2,1,3));
}
@Test

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

@Test
public void mapGroupMerge(){
  for(int k=0;k<ITERATIONS;k++) {
    assertThat(Spouts.of(1)
        .map(i -> nextAsync()).grouped(1)
        .map(l -> Spouts.mergeLatest(l))
        .flatMap(i -> i).toList(), equalTo(Arrays.asList(1, 2)));
  }
}
@Test

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法