本文整理了Java中reactor.util.function.Tuples.fromArray()
方法的一些代码示例,展示了Tuples.fromArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuples.fromArray()
方法的具体详情如下:
包路径:reactor.util.function.Tuples
类名称: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
@Override
public Tuple2 apply(Object o) {
return fromArray((Object[])o);
}
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
* have produced an item, aggregating their values into a {@link Tuple2} and delaying errors.
* If a Mono source completes without value, the other source is run to completion then the
* resulting {@link Mono} completes empty.
* If both Monos error, the two exceptions are combined (as suppressed exceptions on a root exception).
*
* <p>
* <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2> Mono<Tuple2<T1, T2>> zipDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2) {
return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2));
}
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
* have produced an item, aggregating their values into a {@link Tuple3}.
* An error or <strong>empty</strong> completion of any source will cause other sources
* to be cancelled and the resulting Mono to immediately error or complete, respectively.
*
* <p>
* <img class="marble" src="doc-files/marbles/zipFixedSourcesForMono.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param p3 The third upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
* @param <T3> type of the value from p3
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2, T3> Mono<Tuple3<T1, T2, T3>> zip(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3) {
return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3));
}
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Mono Monos}
* have produced an item, aggregating their values into a {@link Tuple3} and delaying errors.
* If a Mono source completes without value, all other sources are run to completion then
* the resulting {@link Mono} completes empty.
* If several Monos error, their exceptions are combined (as suppressed exceptions on a root exception).
*
* <p>
* <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param p3 The third upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
* @param <T3> type of the value from p3
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2, T3> Mono<Tuple3<T1, T2, T3>> zipDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3) {
return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3));
}
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
* have produced an item, aggregating their values into a {@link Tuple4}.
* An error or <strong>empty</strong> completion of any source will cause other sources
* to be cancelled and the resulting Mono to immediately error or complete, respectively.
*
* <p>
* <img class="marble" src="doc-files/marbles/zipFixedSourcesForMono.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param p3 The third upstream {@link Publisher} to subscribe to.
* @param p4 The fourth upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
* @param <T3> type of the value from p3
* @param <T4> type of the value from p4
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2, T3, T4> Mono<Tuple4<T1, T2, T3, T4>> zip(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4) {
return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4));
}
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
* have produced an item, aggregating their values into a {@link Tuple4} and delaying errors.
* If a Mono source completes without value, all other sources are run to completion then
* the resulting {@link Mono} completes empty.
* If several Monos error, their exceptions are combined (as suppressed exceptions on a root exception).
*
* <p>
* <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param p3 The third upstream {@link Publisher} to subscribe to.
* @param p4 The fourth upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
* @param <T3> type of the value from p3
* @param <T4> type of the value from p4
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2, T3, T4> Mono<Tuple4<T1, T2, T3, T4>> zipDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4) {
return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4));
}
代码示例来源:origin: reactor/reactor-core
Mono<? extends T5> p5,
Mono<? extends T6> p6) {
return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5, p6));
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
* have produced an item, aggregating their values into a {@link Tuple5} and delaying errors.
* If a Mono source completes without value, all other sources are run to completion then
* the resulting {@link Mono} completes empty.
* If several Monos error, their exceptions are combined (as suppressed exceptions on a root exception).
* <p>
* <img class="marble" src="doc-files/marbles/zipDelayErrorFixedSources.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param p3 The third upstream {@link Publisher} to subscribe to.
* @param p4 The fourth upstream {@link Publisher} to subscribe to.
* @param p5 The fifth upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
* @param <T3> type of the value from p3
* @param <T4> type of the value from p4
* @param <T5> type of the value from p5
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2, T3, T4, T5> Mono<Tuple5<T1, T2, T3, T4, T5>> zipDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4,
Mono<? extends T5> p5) {
return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5));
}
代码示例来源:origin: reactor/reactor-core
/**
* Merge given monos into a new {@literal Mono} that will be fulfilled when all of the given {@literal Monos}
* have produced an item, aggregating their values into a {@link Tuple5}.
* An error or <strong>empty</strong> completion of any source will cause other sources
* to be cancelled and the resulting Mono to immediately error or complete, respectively.
*
* <p>
* <img class="marble" src="doc-files/marbles/zipFixedSourcesForMono.svg" alt="">
* <p>
* @param p1 The first upstream {@link Publisher} to subscribe to.
* @param p2 The second upstream {@link Publisher} to subscribe to.
* @param p3 The third upstream {@link Publisher} to subscribe to.
* @param p4 The fourth upstream {@link Publisher} to subscribe to.
* @param p5 The fifth upstream {@link Publisher} to subscribe to.
* @param <T1> type of the value from p1
* @param <T2> type of the value from p2
* @param <T3> type of the value from p3
* @param <T4> type of the value from p4
* @param <T5> type of the value from p5
*
* @return a {@link Mono}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T1, T2, T3, T4, T5> Mono<Tuple5<T1, T2, T3, T4, T5>> zip(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4,
Mono<? extends T5> p5) {
return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5));
}
代码示例来源: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 tuple6CreatedFromArray6() {
Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6 };
Tuple2 expected = Tuples.of(1, 2, 3, 4, 5, 6);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual)
.isExactlyInstanceOf(Tuple6.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
@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 tuple3CreatedFromArray3() {
Integer[] source = new Integer[]{1, 2, 3};
Tuple2 expected = Tuples.of(1, 2, 3);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual).isExactlyInstanceOf(Tuple3.class)
.isEqualTo(expected);
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void tuple8CreatedFromArray8() {
Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 };
Tuple2 expected = Tuples.of(1, 2, 3, 4, 5, 6, 7, 8);
Tuple2 actual = Tuples.fromArray(source);
assertThat(actual)
.isExactlyInstanceOf(Tuple8.class)
.isEqualTo(expected);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void fromArrayRejectsNull() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> Tuples.fromArray(null))
.withMessageStartingWith("null or too small array, need between 2 and 8 values");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void fromArrayRejects0() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> Tuples.fromArray(new Object[0]))
.withMessageStartingWith("null or too small array, need between 2 and 8 values");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void fromArrayRejects1() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> Tuples.fromArray(new Object[1]))
.withMessageStartingWith("null or too small array, need between 2 and 8 values");
}
代码示例来源:origin: reactor/reactor-core
@Test
@SuppressWarnings("unchecked")
public void fromArrayRejects9() {
Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> Tuples.fromArray(source))
.withMessage("too many arguments (9), need between 2 and 8 values");
}
内容来源于网络,如有侵权,请联系作者删除!