本文整理了Java中reactor.util.function.Tuples.of()
方法的一些代码示例,展示了Tuples.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuples.of()
方法的具体详情如下:
包路径:reactor.util.function.Tuples
类名称:Tuples
方法名:of
[英]Create a Tuple2 with the given objects.
[中]用给定的对象创建一个Tuple2。
代码示例来源:origin: lettuce-io/lettuce-core
protected void addRequest(RedisURI redisURI, TimedAsyncCommand<String, String, String> command) {
rawViews.put(redisURI, command);
command.onComplete((s, throwable) -> {
if (throwable != null) {
accept(throwable);
} else {
accept(Tuples.of(redisURI, command));
}
});
}
代码示例来源:origin: codecentric/spring-boot-admin
protected Tuple2<String, Flux<Instance>> getApplicationForInstance(Instance instance) {
String name = instance.getRegistration().getName();
return Tuples.of(name, registry.getInstances(name).filter(Instance::isRegistered));
}
代码示例来源:origin: reactor/reactor-core
@Test
public void errorContinueOnMonoReduction() {
AtomicReference<Tuple2<Class, Object>> ref = new AtomicReference<>();
StepVerifier.create(Flux.just(1, 0, 2)
.map(v -> 100 / v)
.reduce((a, b) -> a + b)
.onErrorContinue(ArithmeticException.class, (t, v) -> ref.set(Tuples.of(t.getClass(), v))))
.expectNext(100 + 50)
.verifyComplete();
Assertions.assertThat(ref).hasValue(Tuples.of(ArithmeticException.class, 0));
}
代码示例来源:origin: reactor/reactor-core
@Test
public void taggedAppendedHideMonoTest() {
Mono<Integer> tagged1 = Mono
.just(1)
.hide()
.tag("1", "One")
.tag("2", "Two");
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void tuple2CreatedFromArray2() {
Integer[] source = new Integer[] { 1, 2 };
Tuple2 expected = Tuples.of(1, 2);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual)
.isExactlyInstanceOf(Tuple2.class)
.isEqualTo(expected);
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void tuple5CreatedFromArray5() {
Integer[] source = new Integer[] { 1, 2, 3, 4, 5 };
Tuple2 expected = Tuples.of(1, 2, 3, 4, 5);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual)
.isExactlyInstanceOf(Tuple5.class)
.isEqualTo(expected);
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void tuple4CreatedFromArray4() {
Integer[] source = new Integer[] { 1, 2, 3, 4 };
Tuple2 expected = Tuples.of(1, 2, 3, 4);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual)
.isExactlyInstanceOf(Tuple4.class)
.isEqualTo(expected);
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void tuple7CreatedFromArray7() {
Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7 };
Tuple2 expected = Tuples.of(1, 2, 3, 4, 5, 6, 7);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual)
.isExactlyInstanceOf(Tuple7.class)
.isEqualTo(expected);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT2() {
Tuple2<Integer, String> base = Tuples.of(100, "Foo");
Tuple2<?,?> mapped = base.mapT2(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(2)
.containsExactly(base.getT1(), 3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT3() {
Tuple3<Integer, Integer, String> base = Tuples.of(100, 200, "Foo");
Tuple2<?,?> mapped = base.mapT3(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(3)
.containsExactly(base.getT1(), base.getT2(), 3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT4Null() {
assertThatNullPointerException().isThrownBy(() ->
Tuples.of(1, 2, 3, 4)
.mapT4(i -> null)
).withMessage("t4");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT2Null() {
assertThatNullPointerException().isThrownBy(() ->
Tuples.of(1, 2)
.mapT2(i -> null)
).withMessage("t2");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT3Null() {
assertThatNullPointerException().isThrownBy(() ->
Tuples.of(1, 2, 3)
.mapT3(i -> null)
).withMessage("t3");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT5Null() {
assertThatNullPointerException().isThrownBy(() ->
Tuples.of(1, 2, 3, 4, 5)
.mapT5(i -> null)
).withMessage("t5");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT4() {
Tuple4<Integer, Integer, Integer, String> base = Tuples.of(100, 200, 300, "Foo");
Tuple2<?,?> mapped = base.mapT4(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(4)
.containsExactly(base.getT1(), base.getT2(), base.getT3(), 3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT2() {
Tuple5<Integer, String, Integer, Integer, Integer> base =
Tuples.of(100, "Foo", 300, 400, 500);
Tuple2<?,?> mapped = base.mapT2(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(5)
.containsExactly(base.getT1(), 3, base.getT3(), base.getT4(),
base.getT5());
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT4() {
Tuple6<Integer, Integer, Integer, String, Integer, Integer> base =
Tuples.of(100, 200, 300, "Foo", 500, 600);
Tuple2<?,?> mapped = base.mapT4(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(6)
.containsExactly(base.getT1(), base.getT2(), base.getT3(), 3,
base.getT5(), base.getT6());
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT2() {
Tuple7<Integer, String, Integer, Integer, Integer, Integer, Integer> base =
Tuples.of(100, "Foo", 300, 400, 500, 600, 700);
Tuple2<?,?> mapped = base.mapT2(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(7)
.containsExactly(base.getT1(), 3, base.getT3(), base.getT4(),
base.getT5(), base.getT6(), base.getT7());
}
代码示例来源:origin: reactor/reactor-core
@Test
public void mapT2() {
Tuple8<Integer, String, Integer, Integer, Integer, Integer, Integer, Integer> base =
Tuples.of(100, "Foo", 300, 400, 500, 600, 700, 800);
Tuple2<?,?> mapped = base.mapT2(String::length);
assertThat(mapped).isNotSameAs(base)
.hasSize(8)
.containsExactly(base.getT1(), 3, base.getT3(), base.getT4(),
base.getT5(), base.getT6(), base.getT7(), base.getT8());
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void zip6() {
StepVerifier.create(Flux.zip(Flux.just(1),
Flux.just(2),
Flux.just(3),
Flux.just(4),
Flux.just(5),
Flux.just(6)))
.expectNext(Tuples.of(1, 2, 3, 4, 5, 6))
.verifyComplete();
}
内容来源于网络,如有侵权,请联系作者删除!