本文整理汇总了Java中reactor.util.function.Tuples.of方法的典型用法代码示例。如果您正苦于以下问题:Java Tuples.of方法的具体用法?Java Tuples.of怎么用?Java Tuples.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.util.function.Tuples
的用法示例。
在下文中一共展示了Tuples.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanOperator
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
Flux<Integer> source = Flux.range(1, 4).map(i -> i);
FluxName<Integer> test = new FluxName<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(-1);
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
示例2: scanOperator
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
Mono<Integer> source = Mono.just(1).map(i -> i);
MonoName<Integer> test = new MonoName<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
示例3: scanOperator
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
Flux<Integer> source = Flux.range(1, 4).map(i -> i);
FluxNameFuseable<Integer> test = new FluxNameFuseable<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(-1);
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
示例4: scanOperator
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
ParallelFlux<Integer> source = Flux.range(1, 4).parallel(3);
ParallelFluxName<Integer> test = new ParallelFluxName<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH))
.isEqualTo(256)
.isEqualTo(source.getPrefetch());
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
示例5: scanOperator
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
Mono<Integer> source = Mono.just(1).map(i -> i);
MonoNameFuseable<Integer> test = new MonoNameFuseable<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
示例6: getInstanceDetail
import reactor.util.function.Tuples; //导入方法依赖的package包/类
private Tuple2<ApplicationDetail, InstanceDetail> getInstanceDetail() {
// @formatter:off
ApplicationDetail applicationDetail = ApplicationDetail
.builder()
.instances(2)
.name("my-app")
.stack("stack")
.memoryLimit(1024)
.id("id")
.requestedState("requestedState")
.runningInstances(2)
.url("https://my-app.cfapps.io")
.diskQuota(20)
.build();
InstanceDetail instanceDetail = InstanceDetail
.builder()
.index("0")
.build();
// @formatter:on
return Tuples.of(applicationDetail, instanceDetail);
}
示例7: getSNI
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Override
protected Tuple2<String, Integer> getSNI() {
if (providedAddress instanceof InetSocketAddress) {
InetSocketAddress ipa = (InetSocketAddress) providedAddress;
return Tuples.of(ipa.getHostString(), ipa.getPort());
}
return null;
}
示例8: snapshot
import reactor.util.function.Tuples; //导入方法依赖的package包/类
Tuple2<Long, T> snapshot(T data){
long now = scheduler.now(TimeUnit.MILLISECONDS);
long last = lastTime;
lastTime = now;
long delta = now - last;
return Tuples.of(delta, data);
}
示例9: add
import reactor.util.function.Tuples; //导入方法依赖的package包/类
void add(Publisher<?> parent, String stacktrace) {
//noinspection ConstantConditions
int key = getParentOrThis(Scannable.from(parent));
synchronized (chainOrder) {
int i = 0;
int n = chainOrder.size();
int j = n - 1;
Tuple3<Integer, String, Integer> tmp;
while(j >= 0){
tmp = chainOrder.get(j);
//noinspection ConstantConditions
if(tmp.getT1() == key){
//noinspection ConstantConditions
i = tmp.getT3();
break;
}
j--;
}
for(;;){
Tuple3<Integer, String, Integer> t =
Tuples.of(
parent.hashCode(),
extract(stacktrace, true), i);
if(!chainOrder.contains(t)){
chainOrder.add(t);
break;
}
i++;
}
}
}
示例10: indexMapperReturnsNull
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void indexMapperReturnsNull() {
Flux<String> source = Flux.just("foo", "bar");
Flux<Tuple2<Integer, String>> test = new FluxIndexFuseable<>(source,
(i, v) -> {
if (i == 0L) return Tuples.of(0, v);
return null;
});
StepVerifier.create(test)
.expectNext(Tuples.of(0, "foo"))
.verifyErrorMessage("indexMapper returned a null value at raw index 1 for value bar");
}
示例11: indexMapperThrows
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void indexMapperThrows() {
Flux<String> source = Flux.just("foo", "bar");
Flux<Tuple2<Integer, String>> test = new FluxIndexFuseable<>(source,
(i, v) -> {
if (i == 0L) return Tuples.of(0, v);
throw new IllegalStateException("boom-" + i);
});
StepVerifier.create(test)
.expectNext(Tuples.of(0, "foo"))
.verifyErrorSatisfies(e -> assertThat(e)
.isInstanceOf(IllegalStateException.class)
.hasMessage("boom-1"));
}
示例12: indexMapperReturnsNull
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void indexMapperReturnsNull() {
Flux<String> source = Flux.just("foo", "bar");
Flux<Tuple2<Integer, String>> test = new FluxIndex<>(source,
(i, v) -> {
if (i == 0L) return Tuples.of(0, v);
return null;
});
StepVerifier.create(test)
.expectNext(Tuples.of(0, "foo"))
.verifyErrorMessage("indexMapper returned a null value at raw index 1 for value bar");
}
示例13: indexMapperThrows
import reactor.util.function.Tuples; //导入方法依赖的package包/类
@Test
public void indexMapperThrows() {
Flux<String> source = Flux.just("foo", "bar");
Flux<Tuple2<Integer, String>> test = new FluxIndex<>(source,
(i, v) -> {
if (i == 0L) return Tuples.of(0, v);
throw new IllegalStateException("boom-" + i);
});
StepVerifier.create(test)
.expectNext(Tuples.of(0, "foo"))
.verifyErrorSatisfies(e -> assertThat(e)
.isInstanceOf(IllegalStateException.class)
.hasMessage("boom-1"));
}
示例14: getStatus
import reactor.util.function.Tuples; //导入方法依赖的package包/类
protected Tuple2<String, Instant> getStatus(List<Instance> instances) {
//TODO: Correct is just a second readmodel for groups
Map<String, Instant> statusWithTime = instances.stream()
.collect(toMap(instance -> instance.getStatusInfo().getStatus(),
Instance::getStatusTimestamp, this::getMax));
if (statusWithTime.size() == 1) {
Map.Entry<String, Instant> e = statusWithTime.entrySet().iterator().next();
return Tuples.of(e.getKey(), e.getValue());
}
if (statusWithTime.containsKey(StatusInfo.STATUS_UP)) {
Instant oldestNonUp = statusWithTime.entrySet()
.stream()
.filter(e -> !StatusInfo.STATUS_UP.equals(e.getKey()))
.map(Map.Entry::getValue)
.min(naturalOrder())
.orElse(Instant.EPOCH);
Instant latest = getMax(oldestNonUp, statusWithTime.getOrDefault(StatusInfo.STATUS_UP, Instant.EPOCH));
return Tuples.of(StatusInfo.STATUS_RESTRICTED, latest);
}
return statusWithTime.entrySet()
.stream()
.min(Map.Entry.comparingByKey(StatusInfo.severity()))
.map(e -> Tuples.of(e.getKey(), e.getValue()))
.orElse(Tuples.of(StatusInfo.STATUS_UNKNOWN, Instant.EPOCH));
}
示例15: getApplicationForInstance
import reactor.util.function.Tuples; //导入方法依赖的package包/类
protected Tuple2<String, Flux<Instance>> getApplicationForInstance(Instance instance) {
String name = instance.getRegistration().getName();
return Tuples.of(name, registry.getInstances(name).filter(Instance::isRegistered));
}