reactor.util.context.Context.getOrEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(288)

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

Context.getOrEmpty介绍

[英]Resolve a value given a key within the Context.
[中]在上下文中解析给定键的值。

代码示例

代码示例来源:origin: reactor/reactor-core

static Condition<Context> keyValue(Object k, Object value) {
  return new Condition<>(c -> c.getOrEmpty(k)
                 .map(v -> v.equals(value))
                 .orElse(false),
      "key <%s> with value <%s>", k, value);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void putNonNullWithValue() {
  int expectedSize = c.size() + 1;
  Context put = c.putNonNull("putNonNull", "value");
  assertThat(put).isNotSameAs(c);
  assertThat(put.getOrEmpty("putNonNull")).contains("value");
  assertThat(put.size()).isEqualTo(expectedSize);
}

代码示例来源:origin: reactor/reactor-core

Mono<Tuple2<Integer, String>> doPut(String url, Mono<String> data) {
  Mono<Tuple2<String, Optional<Object>>> dataAndContext =
      data.zipWith(Mono.subscriberContext()
               .map(c -> c.getOrEmpty(HTTP_CORRELATION_ID)));
  return dataAndContext
      .<String>handle((dac, sink) -> {
        if (dac.getT2().isPresent()) {
          sink.next("PUT <" + dac.getT1() + "> sent to " + url + " with header X-Correlation-ID = " + dac.getT2().get());
        }
        else {
          sink.next("PUT <" + dac.getT1() + "> sent to " + url);
        }
        sink.complete();
      })
      .map(msg -> Tuples.of(200, msg));
}

代码示例来源:origin: mulesoft/mule

@Override
public Publisher<CoreEvent> apply(Publisher<CoreEvent> publisher) {
 Flux<CoreEvent> schedulerTrackingPublisher = from(publisher)
   .doOnEach(signal -> signal.getContext().getOrEmpty(PROCESSOR_SCHEDULER_CONTEXT_KEY)
     .ifPresent(sch -> schedulers.add(((Scheduler) sch).getName())));
 if (getProcessingType() == CPU_LITE_ASYNC) {
  return from(schedulerTrackingPublisher).transform(processorPublisher -> Processor.super.apply(schedulerTrackingPublisher))
    .publishOn(fromExecutorService(custom)).onErrorStop();
 } else {
  return Processor.super.apply(schedulerTrackingPublisher);
 }
}

代码示例来源:origin: mulesoft/mule

ctx.getOrEmpty(PROCESSOR_SCHEDULER_CONTEXT_KEY).map(s -> (Scheduler) s).orElse(IMMEDIATE_SCHEDULER);

代码示例来源:origin: org.mule.runtime/mule-core

.transform(doOnNextOrErrorWithContext(context -> context.getOrEmpty(TCCL_REACTOR_CTX_KEY)
  .ifPresent(cl -> currentThread().setContextClassLoader((ClassLoader) cl))))
.transform(next)
.transform(doOnNextOrErrorWithContext(context -> context.getOrEmpty(TCCL_ORIGINAL_REACTOR_CTX_KEY)
  .ifPresent(cl -> currentThread().setContextClassLoader((ClassLoader) cl)))));

相关文章