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

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

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

Tuples.fromArray介绍

[英]Create a Tuple2 with the given array if it is small enough to fit inside a Tuple2 to Tuple8.
[中]如果Tuple2足够小,可以放入Tuple2到Tuple8中,则使用给定数组创建一个Tuple2。

代码示例

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

  1. @Override
  2. public Tuple2 apply(Object o) {
  3. return fromArray((Object[])o);
  4. }

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple2} and delaying errors.
  4. * If a Mono source completes without value, the other source is run to completion then the
  5. * resulting {@link Mono} completes empty.
  6. * If both Monos error, the two exceptions are combined (as suppressed exceptions on a root exception).
  7. *
  8. * <p>
  9. * <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
  10. * <p>
  11. * @param p1 The first upstream {@link Publisher} to subscribe to.
  12. * @param p2 The second upstream {@link Publisher} to subscribe to.
  13. * @param <T1> type of the value from p1
  14. * @param <T2> type of the value from p2
  15. *
  16. * @return a {@link Mono}.
  17. */
  18. @SuppressWarnings({ "unchecked", "rawtypes" })
  19. public static <T1, T2> Mono<Tuple2<T1, T2>> zipDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2) {
  20. return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2));
  21. }

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple3}.
  4. * An error or <strong>empty</strong> completion of any source will cause other sources
  5. * to be cancelled and the resulting Mono to immediately error or complete, respectively.
  6. *
  7. * <p>
  8. * <img class="marble" src="doc-files/marbles/zipFixedSourcesForMono.svg" alt="">
  9. * <p>
  10. * @param p1 The first upstream {@link Publisher} to subscribe to.
  11. * @param p2 The second upstream {@link Publisher} to subscribe to.
  12. * @param p3 The third upstream {@link Publisher} to subscribe to.
  13. * @param <T1> type of the value from p1
  14. * @param <T2> type of the value from p2
  15. * @param <T3> type of the value from p3
  16. *
  17. * @return a {@link Mono}.
  18. */
  19. @SuppressWarnings({ "unchecked", "rawtypes" })
  20. public static <T1, T2, T3> Mono<Tuple3<T1, T2, T3>> zip(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3) {
  21. return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3));
  22. }

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Mono Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple3} and delaying errors.
  4. * If a Mono source completes without value, all other sources are run to completion then
  5. * the resulting {@link Mono} completes empty.
  6. * If several Monos error, their exceptions are combined (as suppressed exceptions on a root exception).
  7. *
  8. * <p>
  9. * <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
  10. * <p>
  11. * @param p1 The first upstream {@link Publisher} to subscribe to.
  12. * @param p2 The second upstream {@link Publisher} to subscribe to.
  13. * @param p3 The third upstream {@link Publisher} to subscribe to.
  14. * @param <T1> type of the value from p1
  15. * @param <T2> type of the value from p2
  16. * @param <T3> type of the value from p3
  17. *
  18. * @return a {@link Mono}.
  19. */
  20. @SuppressWarnings({ "unchecked", "rawtypes" })
  21. public static <T1, T2, T3> Mono<Tuple3<T1, T2, T3>> zipDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3) {
  22. return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3));
  23. }

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple4}.
  4. * An error or <strong>empty</strong> completion of any source will cause other sources
  5. * to be cancelled and the resulting Mono to immediately error or complete, respectively.
  6. *
  7. * <p>
  8. * <img class="marble" src="doc-files/marbles/zipFixedSourcesForMono.svg" alt="">
  9. * <p>
  10. * @param p1 The first upstream {@link Publisher} to subscribe to.
  11. * @param p2 The second upstream {@link Publisher} to subscribe to.
  12. * @param p3 The third upstream {@link Publisher} to subscribe to.
  13. * @param p4 The fourth upstream {@link Publisher} to subscribe to.
  14. * @param <T1> type of the value from p1
  15. * @param <T2> type of the value from p2
  16. * @param <T3> type of the value from p3
  17. * @param <T4> type of the value from p4
  18. *
  19. * @return a {@link Mono}.
  20. */
  21. @SuppressWarnings({ "unchecked", "rawtypes" })
  22. public static <T1, T2, T3, T4> Mono<Tuple4<T1, T2, T3, T4>> zip(Mono<? extends T1> p1,
  23. Mono<? extends T2> p2,
  24. Mono<? extends T3> p3,
  25. Mono<? extends T4> p4) {
  26. return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4));
  27. }

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple4} and delaying errors.
  4. * If a Mono source completes without value, all other sources are run to completion then
  5. * the resulting {@link Mono} completes empty.
  6. * If several Monos error, their exceptions are combined (as suppressed exceptions on a root exception).
  7. *
  8. * <p>
  9. * <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
  10. * <p>
  11. * @param p1 The first upstream {@link Publisher} to subscribe to.
  12. * @param p2 The second upstream {@link Publisher} to subscribe to.
  13. * @param p3 The third upstream {@link Publisher} to subscribe to.
  14. * @param p4 The fourth upstream {@link Publisher} to subscribe to.
  15. * @param <T1> type of the value from p1
  16. * @param <T2> type of the value from p2
  17. * @param <T3> type of the value from p3
  18. * @param <T4> type of the value from p4
  19. *
  20. * @return a {@link Mono}.
  21. */
  22. @SuppressWarnings({ "unchecked", "rawtypes" })
  23. public static <T1, T2, T3, T4> Mono<Tuple4<T1, T2, T3, T4>> zipDelayError(Mono<? extends T1> p1,
  24. Mono<? extends T2> p2,
  25. Mono<? extends T3> p3,
  26. Mono<? extends T4> p4) {
  27. return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4));
  28. }

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

  1. Mono<? extends T5> p5,
  2. Mono<? extends T6> p6) {
  3. return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5, p6));

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple5} and delaying errors.
  4. * If a Mono source completes without value, all other sources are run to completion then
  5. * the resulting {@link Mono} completes empty.
  6. * If several Monos error, their exceptions are combined (as suppressed exceptions on a root exception).
  7. * <p>
  8. * <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
  9. * <p>
  10. * @param p1 The first upstream {@link Publisher} to subscribe to.
  11. * @param p2 The second upstream {@link Publisher} to subscribe to.
  12. * @param p3 The third upstream {@link Publisher} to subscribe to.
  13. * @param p4 The fourth upstream {@link Publisher} to subscribe to.
  14. * @param p5 The fifth upstream {@link Publisher} to subscribe to.
  15. * @param <T1> type of the value from p1
  16. * @param <T2> type of the value from p2
  17. * @param <T3> type of the value from p3
  18. * @param <T4> type of the value from p4
  19. * @param <T5> type of the value from p5
  20. *
  21. * @return a {@link Mono}.
  22. */
  23. @SuppressWarnings({ "unchecked", "rawtypes" })
  24. public static <T1, T2, T3, T4, T5> Mono<Tuple5<T1, T2, T3, T4, T5>> zipDelayError(Mono<? extends T1> p1,
  25. Mono<? extends T2> p2,
  26. Mono<? extends T3> p3,
  27. Mono<? extends T4> p4,
  28. Mono<? extends T5> p5) {
  29. return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5));
  30. }

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

  1. /**
  2. * Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
  3. * have produced an item, aggregating their values into a {@link Tuple5}.
  4. * An error or <strong>empty</strong> completion of any source will cause other sources
  5. * to be cancelled and the resulting Mono to immediately error or complete, respectively.
  6. *
  7. * <p>
  8. * <img class="marble" src="doc-files/marbles/zipFixedSourcesForMono.svg" alt="">
  9. * <p>
  10. * @param p1 The first upstream {@link Publisher} to subscribe to.
  11. * @param p2 The second upstream {@link Publisher} to subscribe to.
  12. * @param p3 The third upstream {@link Publisher} to subscribe to.
  13. * @param p4 The fourth upstream {@link Publisher} to subscribe to.
  14. * @param p5 The fifth upstream {@link Publisher} to subscribe to.
  15. * @param <T1> type of the value from p1
  16. * @param <T2> type of the value from p2
  17. * @param <T3> type of the value from p3
  18. * @param <T4> type of the value from p4
  19. * @param <T5> type of the value from p5
  20. *
  21. * @return a {@link Mono}.
  22. */
  23. @SuppressWarnings({ "unchecked", "rawtypes" })
  24. public static <T1, T2, T3, T4, T5> Mono<Tuple5<T1, T2, T3, T4, T5>> zip(Mono<? extends T1> p1,
  25. Mono<? extends T2> p2,
  26. Mono<? extends T3> p3,
  27. Mono<? extends T4> p4,
  28. Mono<? extends T5> p5) {
  29. return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5));
  30. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple4CreatedFromArray4() {
  4. Integer[] source = new Integer[] { 1, 2, 3, 4 };
  5. Tuple2 expected = Tuples.of(1, 2, 3, 4);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual)
  8. .isExactlyInstanceOf(Tuple4.class)
  9. .isEqualTo(expected);
  10. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple6CreatedFromArray6() {
  4. Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6 };
  5. Tuple2 expected = Tuples.of(1, 2, 3, 4, 5, 6);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual)
  8. .isExactlyInstanceOf(Tuple6.class)
  9. .isEqualTo(expected);
  10. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple7CreatedFromArray7() {
  4. Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7 };
  5. Tuple2 expected = Tuples.of(1, 2, 3, 4, 5, 6, 7);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual)
  8. .isExactlyInstanceOf(Tuple7.class)
  9. .isEqualTo(expected);
  10. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple2CreatedFromArray2() {
  4. Integer[] source = new Integer[] { 1, 2 };
  5. Tuple2 expected = Tuples.of(1, 2);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual)
  8. .isExactlyInstanceOf(Tuple2.class)
  9. .isEqualTo(expected);
  10. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple5CreatedFromArray5() {
  4. Integer[] source = new Integer[] { 1, 2, 3, 4, 5 };
  5. Tuple2 expected = Tuples.of(1, 2, 3, 4, 5);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual)
  8. .isExactlyInstanceOf(Tuple5.class)
  9. .isEqualTo(expected);
  10. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple3CreatedFromArray3() {
  4. Integer[] source = new Integer[]{1, 2, 3};
  5. Tuple2 expected = Tuples.of(1, 2, 3);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual).isExactlyInstanceOf(Tuple3.class)
  8. .isEqualTo(expected);
  9. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void tuple8CreatedFromArray8() {
  4. Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 };
  5. Tuple2 expected = Tuples.of(1, 2, 3, 4, 5, 6, 7, 8);
  6. Tuple2 actual = Tuples.fromArray(source);
  7. assertThat(actual)
  8. .isExactlyInstanceOf(Tuple8.class)
  9. .isEqualTo(expected);
  10. }

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

  1. @Test
  2. public void fromArrayRejectsNull() {
  3. assertThatExceptionOfType(IllegalArgumentException.class)
  4. .isThrownBy(() -> Tuples.fromArray(null))
  5. .withMessageStartingWith("null or too small array, need between 2 and 8 values");
  6. }

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

  1. @Test
  2. public void fromArrayRejects0() {
  3. assertThatExceptionOfType(IllegalArgumentException.class)
  4. .isThrownBy(() -> Tuples.fromArray(new Object[0]))
  5. .withMessageStartingWith("null or too small array, need between 2 and 8 values");
  6. }

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

  1. @Test
  2. public void fromArrayRejects1() {
  3. assertThatExceptionOfType(IllegalArgumentException.class)
  4. .isThrownBy(() -> Tuples.fromArray(new Object[1]))
  5. .withMessageStartingWith("null or too small array, need between 2 and 8 values");
  6. }

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

  1. @Test
  2. @SuppressWarnings("unchecked")
  3. public void fromArrayRejects9() {
  4. Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  5. assertThatExceptionOfType(IllegalArgumentException.class)
  6. .isThrownBy(() -> Tuples.fromArray(source))
  7. .withMessage("too many arguments (9), need between 2 and 8 values");
  8. }

相关文章