Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2011-2018 Pivotal Software Inc, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reactor.core.publisher;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
import reactor.core.Exceptions;
import reactor.core.Scannable;
import reactor.util.annotation.Nullable;
import reactor.util.context.Context;
/**
* Waits for all Mono sources to produce a value or terminate, and if all of them produced
* a value, emit a Tuples of those values; otherwise terminate.
*
* @param the source value types
*/
final class MonoZip extends Mono implements SourceProducer {
final boolean delayError;
final Publisher>[] sources;
final Iterable extends Publisher>> sourcesIterable;
final Function super Object[], ? extends R> zipper;
@SuppressWarnings("unchecked")
MonoZip(boolean delayError,
Publisher extends T> p1,
Publisher extends U> p2,
BiFunction super T, ? super U, ? extends R> zipper2) {
this(delayError,
new FluxZip.PairwiseZipper<>(new BiFunction[]{
Objects.requireNonNull(zipper2, "zipper2")}),
Objects.requireNonNull(p1, "p1"),
Objects.requireNonNull(p2, "p2"));
}
MonoZip(boolean delayError,
Function super Object[], ? extends R> zipper,
Publisher>... sources) {
this.delayError = delayError;
this.zipper = Objects.requireNonNull(zipper, "zipper");
this.sources = Objects.requireNonNull(sources, "sources");
this.sourcesIterable = null;
}
MonoZip(boolean delayError,
Function super Object[], ? extends R> zipper,
Iterable extends Publisher>> sourcesIterable) {
this.delayError = delayError;
this.zipper = Objects.requireNonNull(zipper, "zipper");
this.sources = null;
this.sourcesIterable = Objects.requireNonNull(sourcesIterable, "sourcesIterable");
}
@SuppressWarnings("unchecked")
@Nullable
Mono zipAdditionalSource(Publisher source, BiFunction zipper) {
Publisher[] oldSources = sources;
if (oldSources != null && this.zipper instanceof FluxZip.PairwiseZipper) {
int oldLen = oldSources.length;
Publisher>[] newSources = new Publisher[oldLen + 1];
System.arraycopy(oldSources, 0, newSources, 0, oldLen);
newSources[oldLen] = source;
Function