package reactor.core.publisher;
import java.util.function.Consumer;
import java.util.function.LongConsumer;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
import reactor.core.Fuseable;
import reactor.util.annotation.Nullable;
final class MonoPeekFuseable<T> extends MonoOperator<T, T>
implements Fuseable, SignalPeek<T> {
final Consumer<? super Subscription> onSubscribeCall;
final Consumer<? super T> onNextCall;
final Consumer<? super Throwable> onErrorCall;
final Runnable onCompleteCall;
final LongConsumer onRequestCall;
final Runnable onCancelCall;
MonoPeekFuseable(Mono<? extends T> source,
@Nullable Consumer<? super Subscription> onSubscribeCall,
@Nullable Consumer<? super T> onNextCall,
@Nullable Consumer<? super Throwable> onErrorCall,
@Nullable Runnable onCompleteCall,
@Nullable LongConsumer onRequestCall,
@Nullable Runnable onCancelCall) {
super(source);
this.onSubscribeCall = onSubscribeCall;
this.onNextCall = onNextCall;
this.onErrorCall = onErrorCall;
this.onCompleteCall = onCompleteCall;
this.onRequestCall = onRequestCall;
this.onCancelCall = onCancelCall;
}
@Override
@SuppressWarnings("unchecked")
public void subscribe(CoreSubscriber<? super T> actual) {
if (actual instanceof ConditionalSubscriber) {
source.subscribe(new FluxPeekFuseable.PeekFuseableConditionalSubscriber<>((ConditionalSubscriber<?
super T>) actual, this));
return;
}
source.subscribe(new FluxPeekFuseable.PeekFuseableSubscriber<>(actual, this));
}
@Override
@Nullable
public Consumer<? super Subscription> onSubscribeCall() {
return onSubscribeCall;
}
@Override
@Nullable
public Consumer<? super T> onNextCall() {
return onNextCall;
}
@Override
@Nullable
public Consumer<? super Throwable> onErrorCall() {
return onErrorCall;
}
@Override
@Nullable
public Runnable onCompleteCall() {
return onCompleteCall;
}
@Override
@Nullable
public Runnable onAfterTerminateCall() {
return null;
}
@Override
@Nullable
public LongConsumer onRequestCall() {
return onRequestCall;
}
@Override
@Nullable
public Runnable onCancelCall() {
return onCancelCall;
}
}