reactor.util.function.Tuples.fn3()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(169)

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

Tuples.fn3介绍

[英]A converting function from Object array to Tuple3
[中]从对象数组到Tuple3的转换函数

代码示例

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

  1. /**
  2. * A converting function from Object array to {@link Tuple3} to R.
  3. *
  4. * @param <T1> The type of the first value.
  5. * @param <T2> The type of the second value.
  6. * @param <T3> The type of the third value.
  7. * @param <R> The type of the return value.
  8. * @param delegate the function to delegate to
  9. *
  10. * @return The unchecked conversion function to R.
  11. */
  12. public static <T1, T2, T3, R> Function<Object[], R> fn3(final Function<Tuple3<T1, T2, T3>, R> delegate) {
  13. return objects -> delegate.apply(Tuples.<T1, T2, T3>fn3().apply(objects));
  14. }

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

  1. /**
  2. * Zip three sources together, that is to say wait for all the sources to emit one
  3. * element and combine these elements once into a {@link Tuple3}.
  4. * The operator will continue doing so until any of the sources completes.
  5. * Errors will immediately be forwarded.
  6. * This "Step-Merge" processing is especially useful in Scatter-Gather scenarios.
  7. * <p>
  8. * <img class="marble" src="doc-files/marbles/zipFixedSourcesForFlux.svg" alt="">
  9. *
  10. * @param source1 The first upstream {@link Publisher} to subscribe to.
  11. * @param source2 The second upstream {@link Publisher} to subscribe to.
  12. * @param source3 The third upstream {@link Publisher} to subscribe to.
  13. * @param <T1> type of the value from source1
  14. * @param <T2> type of the value from source2
  15. * @param <T3> type of the value from source3
  16. *
  17. * @return a zipped {@link Flux}
  18. */
  19. public static <T1, T2, T3> Flux<Tuple3<T1, T2, T3>> zip(Publisher<? extends T1> source1,
  20. Publisher<? extends T2> source2,
  21. Publisher<? extends T3> source3) {
  22. return zip(Tuples.fn3(), source1, source2, source3);
  23. }

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

  1. @Test
  2. public void fn3() {
  3. Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 };
  4. Tuple3<Object, Object, Object> tuple = Tuples.fn3().apply(source);
  5. assertThat(tuple.getT1()).isEqualTo(1);
  6. assertThat(tuple.getT2()).isEqualTo(2);
  7. assertThat(tuple.getT3()).isEqualTo(3);
  8. assertThat(tuple)
  9. .isInstanceOf(Tuple8.class)
  10. .containsExactly(1, 2, 3, 4, 5, 6, 7, 8);
  11. }

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

  1. @Test
  2. public void fn3Delegate() {
  3. Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 };
  4. Function<Tuple3<Integer, Integer, Integer>, Tuple3> invert = t3 -> new Tuple3<>(t3.getT3(), t3.getT2(), t3.getT1());
  5. Tuple3 tuple = Tuples.fn3(invert).apply(source);
  6. assertThat(tuple.getT1()).isEqualTo(3);
  7. assertThat(tuple.getT2()).isEqualTo(2);
  8. assertThat(tuple.getT3()).isEqualTo(1);
  9. assertThat((Object) tuple).isExactlyInstanceOf(Tuple3.class);
  10. }

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

  1. @Test
  2. public void whenIterableDoesntCombineErrors() {
  3. Exception boom1 = new NullPointerException("boom1");
  4. Exception boom2 = new IllegalArgumentException("boom2");
  5. StepVerifier.create(Mono.zip(
  6. Arrays.asList(Mono.just("foo"), Mono.<String>error(boom1), Mono.<String>error(boom2)),
  7. Tuples.fn3()))
  8. .verifyErrorMatches(e -> e == boom1);
  9. }

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

  1. @Test
  2. public void whenIterableDelayErrorCombinesErrors() {
  3. Exception boom1 = new NullPointerException("boom1");
  4. Exception boom2 = new IllegalArgumentException("boom2");
  5. StepVerifier.create(Mono.zipDelayError(
  6. Arrays.asList(Mono.just("foo"), Mono.<String>error(boom1), Mono.<String>error(boom2)),
  7. Tuples.fn3()))
  8. .verifyErrorMatches(e -> e.getMessage().equals("Multiple exceptions") &&
  9. e.getSuppressed()[0] == boom1 &&
  10. e.getSuppressed()[1] == boom2);
  11. }

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

  1. /**
  2. * A converting function from Object array to {@link Tuple3} to R.
  3. *
  4. * @param <T1> The type of the first value.
  5. * @param <T2> The type of the second value.
  6. * @param <T3> The type of the third value.
  7. * @param <R> The type of the return value.
  8. * @param delegate the function to delegate to
  9. *
  10. * @return The unchecked conversion function to R.
  11. */
  12. public static <T1, T2, T3, R> Function<Object[], R> fn3(final Function<Tuple3<T1, T2, T3>, R> delegate) {
  13. return objects -> delegate.apply(Tuples.<T1, T2, T3>fn3().apply(objects));
  14. }

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

  1. /**
  2. * Zip three sources together, that is to say wait for all the sources to emit one
  3. * element and combine these elements once into a {@link Tuple3}.
  4. * The operator will continue doing so until any of the sources completes.
  5. * Errors will immediately be forwarded.
  6. * This "Step-Merge" processing is especially useful in Scatter-Gather scenarios.
  7. * <p>
  8. * <img class="marble" src="doc-files/marbles/zipFixedSourcesForFlux.svg" alt="">
  9. *
  10. * @param source1 The first upstream {@link Publisher} to subscribe to.
  11. * @param source2 The second upstream {@link Publisher} to subscribe to.
  12. * @param source3 The third upstream {@link Publisher} to subscribe to.
  13. * @param <T1> type of the value from source1
  14. * @param <T2> type of the value from source2
  15. * @param <T3> type of the value from source3
  16. *
  17. * @return a zipped {@link Flux}
  18. */
  19. public static <T1, T2, T3> Flux<Tuple3<T1, T2, T3>> zip(Publisher<? extends T1> source1,
  20. Publisher<? extends T2> source2,
  21. Publisher<? extends T3> source3) {
  22. return zip(Tuples.fn3(), source1, source2, source3);
  23. }

相关文章