diff --git a/build.gradle b/build.gradle index 3158719363..a3ef8b1834 100644 --- a/build.gradle +++ b/build.gradle @@ -224,7 +224,7 @@ project('reactor-core') { testCompile "org.reactivestreams:reactive-streams-tck:1.0.1" // JSR-305 annotations - optional "com.google.code.findbugs:jsr305:3.0.0" + optional "com.google.code.findbugs:jsr305:3.0.2" //Optional Logging Operator optional "org.slf4j:slf4j-api:$slf4jVersion" diff --git a/reactor-core/src/main/java/reactor/adapter/JdkFlowAdapter.java b/reactor-core/src/main/java/reactor/adapter/JdkFlowAdapter.java index 522f1b5657..6d076250e1 100644 --- a/reactor-core/src/main/java/reactor/adapter/JdkFlowAdapter.java +++ b/reactor-core/src/main/java/reactor/adapter/JdkFlowAdapter.java @@ -23,6 +23,7 @@ import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.publisher.Flux; +import reactor.util.annotation.NonNull; /** * Convert a Java 9+ {@literal Flow.Publisher} to/from a Reactive Streams {@link Publisher}. @@ -39,7 +40,7 @@ public abstract class JdkFlowAdapter { * @param the type of the publisher * @return a java {@code Flow.Publisher} from the given {@link Publisher} */ - public static Flow.Publisher publisherToFlowPublisher(final Publisher + public static Flow.Publisher<@NonNull T> publisherToFlowPublisher(final Publisher<@NonNull T> publisher) { return new PublisherAsFlowPublisher<>(publisher); } @@ -51,19 +52,19 @@ public static Flow.Publisher publisherToFlowPublisher(final Publisher * @param the type of the publisher * @return a {@link Flux} from a java {@code Flow.Publisher} */ - public static Flux flowPublisherToFlux(Flow.Publisher publisher) { + public static Flux<@NonNull T> flowPublisherToFlux(Flow.Publisher<@NonNull T> publisher) { return new FlowPublisherAsFlux<>(publisher); } private static class FlowPublisherAsFlux extends Flux { private final java.util.concurrent.Flow.Publisher pub; - private FlowPublisherAsFlux(java.util.concurrent.Flow.Publisher pub) { + private FlowPublisherAsFlux(java.util.concurrent.Flow.Publisher<@NonNull T> pub) { this.pub = pub; } @Override - public void subscribe(final CoreSubscriber actual) { + public void subscribe(final CoreSubscriber actual) { pub.subscribe(new SubscriberToRS<>(actual)); } } @@ -71,12 +72,12 @@ public void subscribe(final CoreSubscriber actual) { private static class PublisherAsFlowPublisher implements Flow.Publisher { private final Publisher pub; - private PublisherAsFlowPublisher(Publisher pub) { + private PublisherAsFlowPublisher(Publisher<@NonNull T> pub) { this.pub = pub; } @Override - public void subscribe(Flow.Subscriber subscriber) { + public void subscribe(Flow.Subscriber subscriber) { pub.subscribe(new FlowSubscriber<>(subscriber)); } } @@ -87,7 +88,7 @@ private static class FlowSubscriber implements CoreSubscriber, Flow.Subscr Subscription subscription; - public FlowSubscriber(Flow.Subscriber subscriber) { + public FlowSubscriber(Flow.Subscriber subscriber) { this.subscriber = subscriber; } @@ -129,7 +130,7 @@ private static class SubscriberToRS implements Flow.Subscriber, Subscripti Flow.Subscription subscription; - public SubscriberToRS(Subscriber s) { + public SubscriberToRS(Subscriber s) { this.s = s; } diff --git a/reactor-core/src/main/java/reactor/adapter/package-info.java b/reactor-core/src/main/java/reactor/adapter/package-info.java index 2c31ef82ca..c0a7239a5e 100644 --- a/reactor-core/src/main/java/reactor/adapter/package-info.java +++ b/reactor-core/src/main/java/reactor/adapter/package-info.java @@ -26,4 +26,4 @@ @NonNullApi package reactor.adapter; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/core/Disposable.java b/reactor-core/src/main/java/reactor/core/Disposable.java index b70593d40b..ac5e6eb1a8 100644 --- a/reactor-core/src/main/java/reactor/core/Disposable.java +++ b/reactor-core/src/main/java/reactor/core/Disposable.java @@ -18,7 +18,8 @@ import java.util.Collection; import java.util.function.Supplier; -import javax.annotation.Nullable; + +import reactor.util.annotation.Nullable; /** * Indicates that a task or resource can be cancelled/disposed. diff --git a/reactor-core/src/main/java/reactor/core/Disposables.java b/reactor-core/src/main/java/reactor/core/Disposables.java index 86084aefed..0ffe296737 100644 --- a/reactor-core/src/main/java/reactor/core/Disposables.java +++ b/reactor-core/src/main/java/reactor/core/Disposables.java @@ -23,9 +23,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import reactor.util.concurrent.Queues; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A support class that offers factory methods for implementations of the specialized @@ -55,7 +56,7 @@ public static Disposable.Composite composite() { * * @return a pre-filled atomic {@link Disposable.Composite} */ - public static Disposable.Composite composite(Disposable... disposables) { + public static Disposable.Composite composite(Disposable @NonNull ... disposables) { return new CompositeDisposable(disposables); } @@ -66,7 +67,7 @@ public static Disposable.Composite composite(Disposable... disposables) { * @return a pre-filled atomic {@link Disposable.Composite} */ public static Disposable.Composite composite( - Iterable disposables) { + Iterable disposables) { return new CompositeDisposable(disposables); } @@ -146,7 +147,7 @@ static final class CompositeDisposable implements Disposable.Composite, Scannabl * Creates a {@link CompositeDisposable} with the given array of initial elements. * @param disposables the array of {@link Disposable} to start with */ - CompositeDisposable(Disposable... disposables) { + CompositeDisposable(Disposable @NonNull ... disposables) { Objects.requireNonNull(disposables, "disposables is null"); int capacity = disposables.length + 1; @@ -167,7 +168,7 @@ static final class CompositeDisposable implements Disposable.Composite, Scannabl * initial elements. * @param disposables the Iterable sequence of {@link Disposable} to start with */ - CompositeDisposable(Iterable disposables) { + CompositeDisposable(Iterable disposables) { Objects.requireNonNull(disposables, "disposables is null"); this.loadFactor = DEFAULT_LOAD_FACTOR; int c = DEFAULT_CAPACITY; @@ -239,7 +240,7 @@ public boolean add(Disposable d) { } @Override - public boolean addAll(Collection ds) { + public boolean addAll(Collection ds) { Objects.requireNonNull(ds, "ds is null"); if (!disposed) { synchronized (this) { @@ -357,7 +358,7 @@ boolean removeEntry(Disposable value) { } } - boolean removeEntry(int pos, Disposable[] a, int m) { + boolean removeEntry(int pos, Disposable @Nullable [] a, int m) { size--; int last; diff --git a/reactor-core/src/main/java/reactor/core/Exceptions.java b/reactor-core/src/main/java/reactor/core/Exceptions.java index c562cdad63..c3baea4340 100644 --- a/reactor-core/src/main/java/reactor/core/Exceptions.java +++ b/reactor-core/src/main/java/reactor/core/Exceptions.java @@ -22,7 +22,9 @@ import java.util.Objects; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * Global Reactor Core Exception handling and utils to operate on. @@ -102,7 +104,7 @@ public static boolean addThrowable(AtomicReferenceFieldUpdater * suppressed exceptions * @see #addThrowable(AtomicReferenceFieldUpdater, Object, Throwable) */ - public static RuntimeException multiple(Throwable... throwables) { + public static RuntimeException multiple(Throwable @NonNull ... throwables) { CompositeException multiple = new CompositeException(); //noinspection ConstantConditions if (throwables != null) { @@ -127,7 +129,7 @@ public static RuntimeException multiple(Throwable... throwables) { * suppressed exceptions * @see #addThrowable(AtomicReferenceFieldUpdater, Object, Throwable) */ - public static RuntimeException multiple(Iterable throwables) { + public static RuntimeException multiple(Iterable<@NonNull Throwable> throwables) { RuntimeException multiple = new RuntimeException("Multiple exceptions"); //noinspection ConstantConditions if (throwables != null) { diff --git a/reactor-core/src/main/java/reactor/core/Scannable.java b/reactor-core/src/main/java/reactor/core/Scannable.java index 26659be74b..b2c4f86a3c 100644 --- a/reactor-core/src/main/java/reactor/core/Scannable.java +++ b/reactor-core/src/main/java/reactor/core/Scannable.java @@ -18,13 +18,13 @@ import java.util.Iterator; import java.util.Objects; -import java.util.Set; import java.util.Spliterators; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.annotation.Nullable; import reactor.util.function.Tuple2; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A Scannable component exposes state in a non strictly memory consistent way and @@ -214,7 +214,7 @@ public boolean isScanAvailable() { } }; - static Stream recurse(Scannable _s, + static Stream recurse(Scannable _s, Attr key){ Scannable s = Scannable.from(_s.scan(key)); if(!s.isScanAvailable()) { @@ -265,7 +265,7 @@ static Scannable from(@Nullable Object o) { * @return a {@link Stream} navigating the {@link org.reactivestreams.Subscriber} * chain (downward) */ - default Stream actuals() { + default Stream actuals() { return Attr.recurse(this, Attr.ACTUAL); } @@ -274,7 +274,7 @@ default Stream actuals() { * * @return a {@link Stream} of referenced inners (flatmap, multicast etc) */ - default Stream inners() { + default Stream inners() { return Stream.empty(); } @@ -330,7 +330,7 @@ default String operatorName() { * @return a {@link Stream} navigating the {@link org.reactivestreams.Subscription} * chain (upward) */ - default Stream parents() { + default Stream parents() { return Attr.recurse(this, Attr.PARENT); } @@ -361,7 +361,7 @@ default Stream parents() { * */ @Nullable - default T scan(Attr key) { + default T scan(Attr<@Nullable T> key) { @SuppressWarnings("unchecked") T value = (T) scanUnsafe(key); if (value == null) @@ -379,7 +379,7 @@ default T scan(Attr key) { * * @return a value associated to the key or the provided default if unmatched or unresolved */ - default T scanOrDefault(Attr key, T defaultValue) { + default T scanOrDefault(Attr<@Nullable T> key, T defaultValue) { @SuppressWarnings("unchecked") T v = (T) scanUnsafe(key); if (v == null) { @@ -394,7 +394,7 @@ default T scanOrDefault(Attr key, T defaultValue) { * * @return the stream of tags for this {@link Scannable} and its parents */ - default Stream> tags() { + default Stream<@NonNull Tuple2<@NonNull String, @NonNull String>> tags() { Stream> parentTags = parents().flatMap(s -> s.scan(Attr.TAGS)); diff --git a/reactor-core/src/main/java/reactor/core/package-info.java b/reactor-core/src/main/java/reactor/core/package-info.java index 1125b29413..61de3d5959 100644 --- a/reactor-core/src/main/java/reactor/core/package-info.java +++ b/reactor-core/src/main/java/reactor/core/package-info.java @@ -22,4 +22,4 @@ @NonNullApi package reactor.core; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java b/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java index a5146e0fd8..38f7ce606d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java @@ -29,13 +29,13 @@ import java.util.function.Supplier; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.Exceptions; import reactor.core.Scannable; -import reactor.util.context.Context; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * An iterable that consumes a Publisher in a blocking fashion. @@ -74,7 +74,7 @@ public Object scanUnsafe(Attr key) { } @Override - public Iterator iterator() { + public Iterator<@NonNull T> iterator() { SubscriberIterator it = createIterator(); source.subscribe(it); @@ -83,7 +83,7 @@ public Iterator iterator() { } @Override - public Spliterator spliterator() { + public Spliterator<@NonNull T> spliterator() { return stream().spliterator(); // cancellation should be composed through this way } @@ -91,7 +91,7 @@ public Spliterator spliterator() { * @return a {@link Stream} of unknown size with onClose attached to {@link * Subscription#cancel()} */ - public Stream stream() { + public Stream<@NonNull T> stream() { SubscriberIterator it = createIterator(); source.subscribe(it); diff --git a/reactor-core/src/main/java/reactor/core/publisher/BlockingSingleSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/BlockingSingleSubscriber.java index 171d7a2180..6c663e66dd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/BlockingSingleSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/BlockingSingleSubscriber.java @@ -22,7 +22,7 @@ import org.reactivestreams.Subscription; import reactor.core.Disposable; import reactor.core.Exceptions; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; /** * @see https://github.com/reactor/reactive-streams-commons diff --git a/reactor-core/src/main/java/reactor/core/publisher/ConnectableFlux.java b/reactor-core/src/main/java/reactor/core/publisher/ConnectableFlux.java index 15430b84b5..886984eb7d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ConnectableFlux.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ConnectableFlux.java @@ -22,6 +22,7 @@ import reactor.core.Fuseable; import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Schedulers; +import reactor.util.annotation.NonNull; /** * The abstract base class for connectable publishers that let subscribers pile up @@ -42,7 +43,7 @@ public abstract class ConnectableFlux extends Flux { * * @return a {@link Flux} that connects to the upstream source when the first {@link org.reactivestreams.Subscriber} subscribes */ - public final Flux autoConnect() { + public final Flux<@NonNull T> autoConnect() { return autoConnect(1); } @@ -60,7 +61,7 @@ public final Flux autoConnect() { * * @return a {@link Flux} that connects to the upstream source when the given amount of Subscribers subscribed */ - public final Flux autoConnect(int minSubscribers) { + public final Flux<@NonNull T> autoConnect(int minSubscribers) { return autoConnect(minSubscribers, NOOP_DISCONNECT); } @@ -75,7 +76,7 @@ public final Flux autoConnect(int minSubscribers) { * * @return a {@link Flux} that connects to the upstream source when the given amount of subscribers subscribed */ - public final Flux autoConnect(int minSubscribers, Consumer cancelSupport) { + public final Flux<@NonNull T> autoConnect(int minSubscribers, Consumer cancelSupport) { if (minSubscribers == 0) { connect(cancelSupport); return this; @@ -111,7 +112,7 @@ public final Disposable connect() { * @param cancelSupport the callback is called with a Disposable instance that can * be called to disconnect the source, even synchronously. */ - public abstract void connect(Consumer cancelSupport); + public abstract void connect(Consumer cancelSupport); /** * Connects to the upstream source when the first {@link org.reactivestreams.Subscriber} subscribes and disconnects diff --git a/reactor-core/src/main/java/reactor/core/publisher/ConnectableFluxOnAssembly.java b/reactor-core/src/main/java/reactor/core/publisher/ConnectableFluxOnAssembly.java index d78f01e832..097cc1ec8e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ConnectableFluxOnAssembly.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ConnectableFluxOnAssembly.java @@ -16,13 +16,14 @@ package reactor.core.publisher; import java.util.function.Consumer; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.publisher.FluxOnAssembly.AssemblySnapshotException; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * Captures the current stacktrace when this connectable publisher is created and @@ -50,18 +51,18 @@ final class ConnectableFluxOnAssembly extends ConnectableFlux implements final AssemblySnapshotException stacktrace; - ConnectableFluxOnAssembly(ConnectableFlux source) { + ConnectableFluxOnAssembly(ConnectableFlux<@NonNull T> source) { this.source = source; this.stacktrace = new AssemblySnapshotException(); } @Override - public void subscribe(CoreSubscriber actual) { + public void subscribe(CoreSubscriber actual) { FluxOnAssembly.subscribe(actual, source, stacktrace); } @Override - public void connect(Consumer cancelSupport) { + public void connect(Consumer cancelSupport) { source.connect(cancelSupport); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/DelegateProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/DelegateProcessor.java index 2b81b12b2e..c6c5e7b61d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/DelegateProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/DelegateProcessor.java @@ -17,15 +17,14 @@ import java.util.Objects; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; -import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java index 1fc8491287..cfc107f5da 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java @@ -20,12 +20,13 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Scannable; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * Dispatches onNext, onError and onComplete signals to zero-to-many Subscribers. @@ -132,7 +133,7 @@ public void onComplete() { } @Override - public void subscribe(CoreSubscriber actual) { + public void subscribe(CoreSubscriber actual) { Objects.requireNonNull(actual, "subscribe"); DirectInner p = new DirectInner<>(actual, this); @@ -155,7 +156,7 @@ public void subscribe(CoreSubscriber actual) { } @Override - public Stream inners() { + public Stream inners() { return Stream.of(subscribers); } @@ -169,7 +170,7 @@ public long downstreamCount() { return subscribers.length; } - boolean add(DirectInner s) { + boolean add(DirectInner<@NonNull T> s) { DirectInner[] a = subscribers; if (a == TERMINATED) { return false; @@ -193,7 +194,7 @@ boolean add(DirectInner s) { } @SuppressWarnings("unchecked") - void remove(DirectInner s) { + void remove(DirectInner<@NonNull T> s) { DirectInner[] a = subscribers; if (a == TERMINATED || a == EMPTY) { return; @@ -258,7 +259,7 @@ static final class DirectInner implements InnerProducer { static final AtomicLongFieldUpdater REQUESTED = AtomicLongFieldUpdater.newUpdater(DirectInner.class, "requested"); - DirectInner(CoreSubscriber actual, DirectProcessor parent) { + DirectInner(CoreSubscriber actual, DirectProcessor parent) { this.actual = actual; this.parent = parent; } @@ -288,7 +289,7 @@ public Object scanUnsafe(Attr key) { } @Override - public CoreSubscriber actual() { + public CoreSubscriber actual() { return actual; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/DrainUtils.java b/reactor-core/src/main/java/reactor/core/publisher/DrainUtils.java index 91f363d595..98907a6a30 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/DrainUtils.java +++ b/reactor-core/src/main/java/reactor/core/publisher/DrainUtils.java @@ -18,10 +18,11 @@ import java.util.Queue; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.BooleanSupplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; abstract class DrainUtils { @@ -90,8 +91,8 @@ static boolean postCompleteRequest(long n, * @return true if the queue was completely drained or the drain process was cancelled */ static boolean postCompleteDrain(long n, - Subscriber actual, - Queue queue, + Subscriber actual, + Queue<@NonNull T> queue, AtomicLongFieldUpdater field, F instance, BooleanSupplier isCancelled) { @@ -172,8 +173,8 @@ static boolean postCompleteDrain(long n, * @param instance the parent instance of the requested field * @param isCancelled callback to detect cancellation */ - public static void postComplete(CoreSubscriber actual, - Queue queue, + public static void postComplete(CoreSubscriber actual, + Queue<@NonNull T> queue, AtomicLongFieldUpdater field, F instance, BooleanSupplier isCancelled) { @@ -222,8 +223,8 @@ public static void postComplete(CoreSubscriber actual, * @return true if the state indicates a completion state. */ public static boolean postCompleteRequestDelayError(long n, - Subscriber actual, - Queue queue, + Subscriber actual, + Queue<@NonNull T> queue, AtomicLongFieldUpdater field, F instance, BooleanSupplier isCancelled, Throwable error) { @@ -266,8 +267,8 @@ public static boolean postCompleteRequestDelayError(long n, * @return true if the queue was completely drained or the drain process was cancelled */ static boolean postCompleteDrainDelayError(long n, - Subscriber actual, - Queue queue, + Subscriber actual, + Queue<@NonNull T> queue, AtomicLongFieldUpdater field, F instance, BooleanSupplier isCancelled, @@ -338,12 +339,12 @@ static boolean postCompleteDrainDelayError(long n, * @param isCancelled callback to detect cancellation * @param error if not null, the error to signal after the queue has been drained */ - public static void postCompleteDelayError(CoreSubscriber actual, - Queue queue, + public static void postCompleteDelayError(CoreSubscriber actual, + Queue<@NonNull T> queue, AtomicLongFieldUpdater field, F instance, BooleanSupplier isCancelled, - @Nullable Throwable error) { + @Nullable Throwable error) { if (queue.isEmpty()) { if (error == null) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java index 56c45d5e50..73b3c14eed 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.concurrent.locks.LockSupport; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -31,6 +30,8 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.concurrent.Queues; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; import static reactor.core.publisher.FluxPublish.PublishSubscriber.EMPTY; import static reactor.core.publisher.FluxPublish.PublishSubscriber.TERMINATED; @@ -62,7 +63,7 @@ public final class EmitterProcessor extends FluxProcessor { * * @return a fresh processor */ - public static EmitterProcessor create() { + public static EmitterProcessor<@NonNull E> create() { return create(Queues.SMALL_BUFFER_SIZE, true); } @@ -154,12 +155,12 @@ public static EmitterProcessor create(int bufferSize, boolean autoCancel) } @Override - public Stream inners() { + public Stream inners() { return Stream.of(subscribers); } @Override - public void subscribe(CoreSubscriber actual) { + public void subscribe(CoreSubscriber actual) { Objects.requireNonNull(actual, "subscribe"); EmitterInner inner = new EmitterInner<>(actual, this); actual.onSubscribe(inner); @@ -441,7 +442,7 @@ final void drain() { } @SuppressWarnings("unchecked") - FluxPublish.PubSubInner[] terminate() { + FluxPublish.PubSubInner<@NonNull T> @NonNull[] terminate() { return SUBSCRIBERS.getAndSet(this, TERMINATED); } @@ -478,7 +479,7 @@ else if (empty) { return false; } - final boolean add(EmitterInner inner) { + final boolean add(EmitterInner<@NonNull T> inner) { for (; ; ) { FluxPublish.PubSubInner[] a = subscribers; if (a == TERMINATED) { @@ -494,7 +495,7 @@ final boolean add(EmitterInner inner) { } } - final void remove(FluxPublish.PubSubInner inner) { + final void remove(FluxPublish.PubSubInner<@NonNull T> inner) { for (; ; ) { FluxPublish.PubSubInner[] a = subscribers; if (a == TERMINATED || a == EMPTY) { @@ -547,7 +548,7 @@ static final class EmitterInner extends FluxPublish.PubSubInner { final EmitterProcessor parent; - EmitterInner(CoreSubscriber actual, EmitterProcessor parent) { + EmitterInner(CoreSubscriber actual, EmitterProcessor<@NonNull T> parent) { super(actual); this.parent = parent; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java index c66f948d0f..d25709de26 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java @@ -35,7 +35,9 @@ import reactor.core.Scannable; import reactor.util.concurrent.Queues; import reactor.util.concurrent.WaitStrategy; -import javax.annotation.Nullable; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; + /** * A base processor used by executor backed processors to take care of their ExecutorService @@ -45,7 +47,7 @@ abstract class EventLoopProcessor extends FluxProcessor implements Runnable { - static Flux coldSource(RingBuffer> ringBuffer, + static Flux coldSource(RingBuffer<@NonNull Slot<@NonNull E>> ringBuffer, @Nullable Throwable t, @Nullable Throwable error, RingBuffer.Sequence start){ @@ -86,7 +88,7 @@ static Flux coldSource(RingBuffer> ringBuffer, static Runnable createRequestTask( Subscription upstream, EventLoopProcessor p, - @Nullable Consumer postWaitCallback, LongSupplier readCount) { + @Nullable Consumer<@NonNull Long> postWaitCallback, LongSupplier readCount) { return new RequestTask(upstream, p, postWaitCallback, readCount); } @@ -205,7 +207,7 @@ static long getAndSub(RingBuffer.Sequence sequence, long toSub) { ExecutorService requestExecutor, boolean autoCancel, boolean multiproducers, - Supplier> factory, + Supplier<@NonNull Slot<@NonNull IN>> factory, WaitStrategy strategy) { if (!Queues.isPowerOfTwo(bufferSize)) { @@ -324,7 +326,7 @@ public final boolean awaitAndShutdown(long timeout, TimeUnit timeUnit) { //FIXME store current subscribers @Override - public Stream inners() { + public Stream inners() { return Stream.empty(); } @@ -334,7 +336,7 @@ public Stream inners() { * * @return a {@link Flux} sequence possibly unbounded of incoming buffered values or empty if not supported. */ - public Flux drain(){ + public Flux<@NonNull IN> drain(){ return Flux.empty(); } @@ -343,7 +345,7 @@ public Flux drain(){ * not yet been executed. * @return a Flux instance with the remaining undelivered values */ - final public Flux forceShutdown() { + final public Flux<@NonNull IN> forceShutdown() { int t = terminated; if (t != FORCED_SHUTDOWN && TERMINATED.compareAndSet(this, t, FORCED_SHUTDOWN)) { executor.shutdownNow(); @@ -485,7 +487,7 @@ static final class RequestTask implements Runnable { RequestTask(Subscription upstream, EventLoopProcessor p, - @Nullable Consumer postWaitCallback, + @Nullable Consumer<@NonNull Long> postWaitCallback, LongSupplier readCount) { this.parent = p; this.readCount = readCount; diff --git a/reactor-core/src/main/java/reactor/core/publisher/Flux.java b/reactor-core/src/main/java/reactor/core/publisher/Flux.java index 540c088249..58f38003e7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Flux.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Flux.java @@ -45,7 +45,6 @@ import java.util.logging.Level; import java.util.stream.Collector; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -68,6 +67,8 @@ import reactor.util.function.Tuple5; import reactor.util.function.Tuple6; import reactor.util.function.Tuples; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A Reactive Streams {@link Publisher} with rx operators that emits 0 to N elements, and then completes @@ -123,7 +124,7 @@ public abstract class Flux implements Publisher { * @return a {@link Flux} based on the produced combinations */ @SafeVarargs - public static Flux combineLatest(Function combinator, Publisher... sources) { + public static Flux<@NonNull V> combineLatest(Function<@NonNull Object @NonNull [], @NonNull V> combinator, Publisher @NonNull ... sources) { return combineLatest(combinator, Queues.XS_BUFFER_SIZE, sources); } @@ -144,8 +145,8 @@ public static Flux combineLatest(Function combinator, Pub * @return a {@link Flux} based on the produced combinations */ @SafeVarargs - public static Flux combineLatest(Function combinator, int prefetch, - Publisher... sources) { + public static Flux<@NonNull V> combineLatest(Function<@NonNull Object @NonNull [], @NonNull V> combinator, int prefetch, + Publisher @NonNull ... sources) { if (sources.length == 0) { return empty(); } @@ -182,9 +183,9 @@ public static Flux combineLatest(Function combinator, int * @return a {@link Flux} based on the produced combinations */ @SuppressWarnings("unchecked") - public static Flux combineLatest(Publisher source1, - Publisher source2, - BiFunction combinator) { + public static Flux<@NonNull V> combineLatest(Publisher source1, + Publisher source2, + BiFunction combinator) { return combineLatest(tuple -> combinator.apply((T1)tuple[0], (T2)tuple[1]), source1, source2); } @@ -207,10 +208,10 @@ public static Flux combineLatest(Publisher source1, * * @return a {@link Flux} based on the produced combinations */ - public static Flux combineLatest(Publisher source1, - Publisher source2, - Publisher source3, - Function combinator) { + public static Flux<@NonNull V> combineLatest(Publisher source1, + Publisher source2, + Publisher source3, + Function<@NonNull Object @NonNull [], @NonNull V> combinator) { return combineLatest(combinator, source1, source2, source3); } @@ -235,11 +236,11 @@ public static Flux combineLatest(Publisher sour * * @return a {@link Flux} based on the produced combinations */ - public static Flux combineLatest(Publisher source1, - Publisher source2, - Publisher source3, - Publisher source4, - Function combinator) { + public static Flux<@NonNull V> combineLatest(Publisher source1, + Publisher source2, + Publisher source3, + Publisher source4, + Function<@NonNull Object @NonNull [], @NonNull V> combinator) { return combineLatest(combinator, source1, source2, source3, source4); } @@ -266,12 +267,12 @@ public static Flux combineLatest(Publisher * * @return a {@link Flux} based on the produced combinations */ - public static Flux combineLatest(Publisher source1, - Publisher source2, - Publisher source3, - Publisher source4, - Publisher source5, - Function combinator) { + public static Flux<@NonNull V> combineLatest(Publisher source1, + Publisher source2, + Publisher source3, + Publisher source4, + Publisher source5, + Function<@NonNull Object @NonNull [], @NonNull V> combinator) { return combineLatest(combinator, source1, source2, source3, source4, source5); } @@ -300,13 +301,13 @@ public static Flux combineLatest(Publisher Flux combineLatest(Publisher source1, - Publisher source2, - Publisher source3, - Publisher source4, - Publisher source5, - Publisher source6, - Function combinator) { + public static Flux<@NonNull V> combineLatest(Publisher source1, + Publisher source2, + Publisher source3, + Publisher source4, + Publisher source5, + Publisher source6, + Function<@NonNull Object @NonNull [], @NonNull V> combinator) { return combineLatest(combinator, source1, source2, source3, source4, source5, source6); } @@ -325,8 +326,8 @@ public static Flux combineLatest(Publisher Flux combineLatest(Iterable> sources, - Function combinator) { + public static Flux<@NonNull V> combineLatest(Iterable> sources, + Function<@NonNull Object @NonNull [], @NonNull V> combinator) { return combineLatest(sources, Queues.XS_BUFFER_SIZE, combinator); } @@ -346,9 +347,9 @@ public static Flux combineLatest(Iterable Flux combineLatest(Iterable> sources, + public static Flux<@NonNull V> combineLatest(Iterable> sources, int prefetch, - Function combinator) { + Function<@NonNull Object @NonNull [], @NonNull V> combinator) { return onAssembly(new FluxCombineLatest(sources, combinator, @@ -371,7 +372,7 @@ public static Flux combineLatest(Iterable Flux concat(Iterable> sources) { + public static Flux<@NonNull T> concat(Iterable> sources) { return onAssembly(new FluxConcatIterable<>(sources)); } @@ -391,7 +392,7 @@ public static Flux concat(Iterable> sour * * @return a new {@link Flux} concatenating all inner sources sequences */ - public static Flux concat(Publisher> sources) { + public static Flux<@NonNull T> concat(Publisher> sources) { return concat(sources, Queues.XS_BUFFER_SIZE); } @@ -412,7 +413,7 @@ public static Flux concat(Publisher> sou * * @return a new {@link Flux} concatenating all inner sources sequences */ - public static Flux concat(Publisher> sources, int prefetch) { + public static Flux<@NonNull T> concat(Publisher> sources, int prefetch) { return onAssembly(new FluxConcatMap<>(from(sources), identityFunction(), Queues.get(prefetch), prefetch, @@ -436,7 +437,7 @@ public static Flux concat(Publisher> sou * @return a new {@link Flux} concatenating all source sequences */ @SafeVarargs - public static Flux concat(Publisher... sources) { + public static Flux<@NonNull T> concat(Publisher @NonNull ... sources) { return onAssembly(new FluxConcatArray<>(false, sources)); } @@ -456,7 +457,7 @@ public static Flux concat(Publisher... sources) { * * @return a new {@link Flux} concatenating all inner sources sequences, delaying errors */ - public static Flux concatDelayError(Publisher> sources) { + public static Flux<@NonNull T> concatDelayError(Publisher> sources) { return concatDelayError(sources, Queues.XS_BUFFER_SIZE); } @@ -477,7 +478,7 @@ public static Flux concatDelayError(Publisher Flux concatDelayError(Publisher> sources, int prefetch) { + public static Flux<@NonNull T> concatDelayError(Publisher> sources, int prefetch) { return onAssembly(new FluxConcatMap<>(from(sources), identityFunction(), Queues.get(prefetch), prefetch, @@ -506,8 +507,8 @@ public static Flux concatDelayError(Publisher Flux concatDelayError(Publisher> sources, boolean delayUntilEnd, int prefetch) { + public static Flux<@NonNull T> concatDelayError(Publisher> sources, boolean delayUntilEnd, int prefetch) { return onAssembly(new FluxConcatMap<>(from(sources), identityFunction(), Queues.get(prefetch), prefetch, @@ -531,7 +532,7 @@ public static Flux concatDelayError(Publisher Flux concatDelayError(Publisher... sources) { + public static Flux<@NonNull T> concatDelayError(Publisher @NonNull ... sources) { return onAssembly(new FluxConcatArray<>(true, sources)); } @@ -568,7 +569,7 @@ public static Flux concatDelayError(Publisher... sources) { * @param emitter Consume the {@link FluxSink} provided per-subscriber by Reactor to generate signals. * @return a {@link Flux} */ - public static Flux create(Consumer> emitter) { + public static Flux<@NonNull T> create(Consumer> emitter) { return create(emitter, OverflowStrategy.BUFFER); } @@ -607,7 +608,7 @@ public static Flux create(Consumer> emitter) { * @param emitter Consume the {@link FluxSink} provided per-subscriber by Reactor to generate signals. * @return a {@link Flux} */ - public static Flux create(Consumer> emitter, OverflowStrategy backpressure) { + public static Flux<@NonNull T> create(Consumer> emitter, OverflowStrategy backpressure) { return onAssembly(new FluxCreate<>(emitter, backpressure, FluxCreate.CreateMode.PUSH_PULL)); } @@ -644,7 +645,7 @@ public static Flux create(Consumer> emitter, Overflow * @param emitter Consume the {@link FluxSink} provided per-subscriber by Reactor to generate signals. * @return a {@link Flux} */ - public static Flux push(Consumer> emitter) { + public static Flux<@NonNull T> push(Consumer> emitter) { return onAssembly(new FluxCreate<>(emitter, OverflowStrategy.BUFFER, FluxCreate.CreateMode.PUSH_ONLY)); } @@ -683,7 +684,7 @@ public static Flux push(Consumer> emitter) { * @param emitter Consume the {@link FluxSink} provided per-subscriber by Reactor to generate signals. * @return a {@link Flux} */ - public static Flux push(Consumer> emitter, OverflowStrategy backpressure) { + public static Flux<@NonNull T> push(Consumer> emitter, OverflowStrategy backpressure) { return onAssembly(new FluxCreate<>(emitter, backpressure, FluxCreate.CreateMode.PUSH_ONLY)); } @@ -702,7 +703,7 @@ public static Flux push(Consumer> emitter, OverflowSt * * @return a deferred {@link Flux} */ - public static Flux defer(Supplier> supplier) { + public static Flux<@NonNull T> defer(Supplier> supplier) { return onAssembly(new FluxDefer<>(supplier)); } @@ -715,7 +716,7 @@ public static Flux defer(Supplier> supplier) { * * @return an empty {@link Flux} */ - public static Flux empty() { + public static Flux<@NonNull T> empty() { return FluxEmpty.instance(); } @@ -730,7 +731,7 @@ public static Flux empty() { * * @return a new failed {@link Flux} */ - public static Flux error(Throwable error) { + public static Flux<@NonNull T> error(Throwable error) { return error(error, false); } @@ -747,7 +748,7 @@ public static Flux error(Throwable error) { * * @return a new failed {@link Flux} */ - public static Flux error(Throwable throwable, boolean whenRequested) { + public static Flux<@NonNull O> error(Throwable throwable, boolean whenRequested) { if (whenRequested) { return onAssembly(new FluxErrorOnRequest<>(throwable)); } @@ -771,7 +772,7 @@ public static Flux error(Throwable throwable, boolean whenRequested) { * @return a new {@link Flux} behaving like the fastest of its sources */ @SafeVarargs - public static Flux first(Publisher... sources) { + public static Flux<@NonNull I> first(Publisher @NonNull ... sources) { return onAssembly(new FluxFirstEmitting<>(sources)); } @@ -789,7 +790,7 @@ public static Flux first(Publisher... sources) { * * @return a new {@link Flux} behaving like the fastest of its sources */ - public static Flux first(Iterable> sources) { + public static Flux<@NonNull I> first(Iterable> sources) { return onAssembly(new FluxFirstEmitting<>(sources)); } @@ -803,7 +804,7 @@ public static Flux first(Iterable> sourc * * @return a new {@link Flux} */ - public static Flux from(Publisher source) { + public static Flux<@NonNull T> from(Publisher source) { if (source instanceof Flux) { @SuppressWarnings("unchecked") Flux casted = (Flux) source; @@ -836,7 +837,7 @@ public static Flux from(Publisher source) { * * @return a new {@link Flux} */ - public static Flux fromArray(T[] array) { + public static Flux<@NonNull T> fromArray(@NonNull T @NonNull [] array) { if (array.length == 0) { return empty(); } @@ -857,7 +858,7 @@ public static Flux fromArray(T[] array) { * * @return a new {@link Flux} */ - public static Flux fromIterable(Iterable it) { + public static Flux<@NonNull T> fromIterable(Iterable it) { return onAssembly(new FluxIterable<>(it)); } @@ -874,7 +875,7 @@ public static Flux fromIterable(Iterable it) { * * @return a new {@link Flux} */ - public static Flux fromStream(Stream s) { + public static Flux<@NonNull T> fromStream(Stream s) { return onAssembly(new FluxStream<>(s)); } @@ -891,7 +892,7 @@ public static Flux fromStream(Stream s) { * * @return a {@link Flux} */ - public static Flux generate(Consumer> generator) { + public static Flux<@NonNull T> generate(Consumer<@NonNull SynchronousSink<@NonNull T>> generator) { Objects.requireNonNull(generator, "generator"); return onAssembly(new FluxGenerate<>(generator)); } @@ -911,7 +912,7 @@ public static Flux generate(Consumer> generator) { * and return a (new) state. * @return a {@link Flux} */ - public static Flux generate(Callable stateSupplier, BiFunction, S> generator) { + public static Flux<@NonNull T> generate(Callable<@Nullable S> stateSupplier, BiFunction<@NonNull S, SynchronousSink<@NonNull T>, @NonNull S> generator) { return onAssembly(new FluxGenerate<>(stateSupplier, generator)); } @@ -935,7 +936,7 @@ public static Flux generate(Callable stateSupplier, BiFunction Flux generate(Callable stateSupplier, BiFunction, S> generator, Consumer stateConsumer) { + public static Flux<@NonNull T> generate(Callable<@Nullable S> stateSupplier, BiFunction<@NonNull S, SynchronousSink<@NonNull T>, @NonNull S> generator, Consumer stateConsumer) { return onAssembly(new FluxGenerate<>(stateSupplier, generator, stateConsumer)); } @@ -951,7 +952,7 @@ public static Flux generate(Callable stateSupplier, BiFunction interval(Duration period) { + public static Flux<@NonNull Long> interval(Duration period) { return interval(period, Schedulers.parallel()); } @@ -969,7 +970,7 @@ public static Flux interval(Duration period) { * * @return a new {@link Flux} emitting increasing numbers at regular intervals */ - public static Flux interval(Duration delay, Duration period) { + public static Flux<@NonNull Long> interval(Duration delay, Duration period) { return interval(delay, period, Schedulers.parallel()); } @@ -985,7 +986,7 @@ public static Flux interval(Duration delay, Duration period) { * * @return a new {@link Flux} emitting increasing numbers at regular intervals */ - public static Flux interval(Duration period, Scheduler timer) { + public static Flux<@NonNull Long> interval(Duration period, Scheduler timer) { return onAssembly(new FluxInterval(period.toMillis(), period.toMillis(), TimeUnit.MILLISECONDS, timer)); } @@ -1003,7 +1004,7 @@ public static Flux interval(Duration period, Scheduler timer) { * * @return a new {@link Flux} emitting increasing numbers at regular intervals */ - public static Flux interval(Duration delay, Duration period, Scheduler timer) { + public static Flux<@NonNull Long> interval(Duration delay, Duration period, Scheduler timer) { return onAssembly(new FluxInterval(delay.toMillis(), period.toMillis(), TimeUnit.MILLISECONDS, timer)); } @@ -1018,7 +1019,7 @@ public static Flux interval(Duration delay, Duration period, Scheduler tim * @return a new {@link Flux} */ @SafeVarargs - public static Flux just(T... data) { + public static Flux<@NonNull T> just(@NonNull T @NonNull ... data) { return fromArray(data); } @@ -1032,7 +1033,7 @@ public static Flux just(T... data) { * * @return a new {@link Flux} */ - public static Flux just(T data) { + public static Flux<@NonNull T> just(T data) { return onAssembly(new FluxJust<>(data)); } @@ -1053,7 +1054,7 @@ public static Flux just(T data) { * * @return a merged {@link Flux} */ - public static Flux merge(Publisher> source) { + public static Flux<@NonNull T> merge(Publisher> source) { return merge(source, Queues.SMALL_BUFFER_SIZE, Queues.XS_BUFFER_SIZE); @@ -1078,7 +1079,7 @@ public static Flux merge(Publisher> sour * * @return a merged {@link Flux} */ - public static Flux merge(Publisher> source, int concurrency) { + public static Flux<@NonNull T> merge(Publisher> source, int concurrency) { return merge(source, concurrency, Queues.XS_BUFFER_SIZE); } @@ -1102,7 +1103,7 @@ public static Flux merge(Publisher> sour * * @return a merged {@link Flux} */ - public static Flux merge(Publisher> source, int concurrency, int prefetch) { + public static Flux<@NonNull T> merge(Publisher> source, int concurrency, int prefetch) { return onAssembly(new FluxFlatMap<>( from(source), identityFunction(), @@ -1131,7 +1132,7 @@ public static Flux merge(Publisher> sour * * @return a merged {@link Flux} */ - public static Flux merge(Iterable> sources) { + public static Flux<@NonNull I> merge(Iterable> sources) { return merge(fromIterable(sources)); } @@ -1153,7 +1154,7 @@ public static Flux merge(Iterable> sourc * @return a merged {@link Flux} */ @SafeVarargs - public static Flux merge(Publisher... sources) { + public static Flux<@NonNull I> merge(Publisher @NonNull ... sources) { return merge(Queues.XS_BUFFER_SIZE, sources); } @@ -1176,7 +1177,7 @@ public static Flux merge(Publisher... sources) { * @return a fresh Reactive {@link Flux} publisher ready to be subscribed */ @SafeVarargs - public static Flux merge(int prefetch, Publisher... sources) { + public static Flux<@NonNull I> merge(int prefetch, Publisher @NonNull ... sources) { return merge(prefetch, false, sources); } @@ -1200,7 +1201,7 @@ public static Flux merge(int prefetch, Publisher... sources) * @return a fresh Reactive {@link Flux} publisher ready to be subscribed */ @SafeVarargs - public static Flux mergeDelayError(int prefetch, Publisher... sources) { + public static Flux<@NonNull I> mergeDelayError(int prefetch, Publisher @NonNull ... sources) { return merge(prefetch, true, sources); } @@ -1217,7 +1218,7 @@ public static Flux mergeDelayError(int prefetch, Publisher.. * * @return a merged {@link Flux}, subscribing early but keeping the original ordering */ - public static Flux mergeSequential(Publisher> sources) { + public static Flux<@NonNull T> mergeSequential(Publisher> sources) { return mergeSequential(sources, false, Queues.SMALL_BUFFER_SIZE, Queues.XS_BUFFER_SIZE); } @@ -1237,7 +1238,7 @@ public static Flux mergeSequential(Publisher Flux mergeSequential(Publisher> sources, + public static Flux<@NonNull T> mergeSequential(Publisher> sources, int maxConcurrency, int prefetch) { return mergeSequential(sources, false, maxConcurrency, prefetch); } @@ -1258,7 +1259,7 @@ public static Flux mergeSequential(Publisher Flux mergeSequentialDelayError(Publisher> sources, + public static Flux<@NonNull T> mergeSequentialDelayError(Publisher> sources, int maxConcurrency, int prefetch) { return mergeSequential(sources, true, maxConcurrency, prefetch); } @@ -1276,7 +1277,7 @@ public static Flux mergeSequentialDelayError(Publisher Flux mergeSequential(Publisher... sources) { + public static Flux<@NonNull I> mergeSequential(Publisher @NonNull ... sources) { return mergeSequential(Queues.XS_BUFFER_SIZE, false, sources); } @@ -1294,7 +1295,7 @@ public static Flux mergeSequential(Publisher... sources) { * @return a merged {@link Flux}, subscribing early but keeping the original ordering */ @SafeVarargs - public static Flux mergeSequential(int prefetch, Publisher... sources) { + public static Flux<@NonNull I> mergeSequential(int prefetch, Publisher @NonNull ... sources) { return mergeSequential(prefetch, false, sources); } @@ -1314,7 +1315,7 @@ public static Flux mergeSequential(int prefetch, Publisher.. * @return a merged {@link Flux}, subscribing early but keeping the original ordering */ @SafeVarargs - public static Flux mergeSequentialDelayError(int prefetch, Publisher... sources) { + public static Flux<@NonNull I> mergeSequentialDelayError(int prefetch, Publisher @NonNull ... sources) { return mergeSequential(prefetch, true, sources); } @@ -1330,7 +1331,7 @@ public static Flux mergeSequentialDelayError(int prefetch, Publisher Flux mergeSequential(Iterable> sources) { + public static Flux<@NonNull I> mergeSequential(Iterable> sources) { return mergeSequential(sources, false, Queues.SMALL_BUFFER_SIZE, Queues.XS_BUFFER_SIZE); } @@ -1350,7 +1351,7 @@ public static Flux mergeSequential(Iterable Flux mergeSequential(Iterable> sources, + public static Flux<@NonNull I> mergeSequential(Iterable> sources, int maxConcurrency, int prefetch) { return mergeSequential(sources, false, maxConcurrency, prefetch); } @@ -1372,7 +1373,7 @@ public static Flux mergeSequential(Iterable Flux mergeSequentialDelayError(Iterable> sources, + public static Flux<@NonNull I> mergeSequentialDelayError(Iterable> sources, int maxConcurrency, int prefetch) { return mergeSequential(sources, true, maxConcurrency, prefetch); } @@ -1386,7 +1387,7 @@ public static Flux mergeSequentialDelayError(Iterable Flux never() { + public static Flux<@NonNull T> never() { return FluxNever.instance(); } @@ -1402,7 +1403,7 @@ public static Flux never() { * @param count the total number of incrementing values to emit, including the first value * @return a ranged {@link Flux} */ - public static Flux range(int start, int count) { + public static Flux<@NonNull Integer> range(int start, int count) { if (count == 1) { return just(start); } @@ -1428,7 +1429,7 @@ public static Flux range(int start, int count) { * * @return a {@link FluxProcessor} accepting publishers and producing T */ - public static Flux switchOnNext(Publisher> mergedPublishers) { + public static Flux<@NonNull T> switchOnNext(Publisher> mergedPublishers) { return switchOnNext(mergedPublishers, Queues.XS_BUFFER_SIZE); } @@ -1449,7 +1450,7 @@ public static Flux switchOnNext(Publisher Flux switchOnNext(Publisher> mergedPublishers, int prefetch) { + public static Flux<@NonNull T> switchOnNext(Publisher> mergedPublishers, int prefetch) { return onAssembly(new FluxSwitchMap<>(from(mergedPublishers), identityFunction(), Queues.unbounded(prefetch), prefetch)); @@ -1474,8 +1475,8 @@ public static Flux switchOnNext(Publisher Flux using(Callable resourceSupplier, Function> sourceSupplier, Consumer resourceCleanup) { + public static Flux<@NonNull T> using(Callable resourceSupplier, Function> sourceSupplier, Consumer resourceCleanup) { return using(resourceSupplier, sourceSupplier, resourceCleanup, true); } @@ -1499,8 +1500,8 @@ public static Flux using(Callable resourceSupplier, Funct * * @return a new {@link Flux} built around a disposable resource */ - public static Flux using(Callable resourceSupplier, Function> sourceSupplier, Consumer resourceCleanup, boolean eager) { + public static Flux<@NonNull T> using(Callable resourceSupplier, Function> sourceSupplier, Consumer resourceCleanup, boolean eager) { return onAssembly(new FluxUsing<>(resourceSupplier, sourceSupplier, resourceCleanup, @@ -1527,9 +1528,9 @@ public static Flux using(Callable resourceSupplier, Funct * * @return a zipped {@link Flux} */ - public static Flux zip(Publisher source1, - Publisher source2, - final BiFunction combinator) { + public static Flux<@NonNull O> zip(Publisher source1, + Publisher source2, + final BiFunction combinator) { return onAssembly(new FluxZip(source1, source2, @@ -1554,7 +1555,7 @@ public static Flux zip(Publisher source1, * * @return a zipped {@link Flux} */ - public static Flux> zip(Publisher source1, Publisher source2) { + public static Flux<@NonNull Tuple2<@NonNull T1, @NonNull T2>> zip(Publisher source1, Publisher source2) { return zip(source1, source2, tuple2Function()); } @@ -1576,9 +1577,9 @@ public static Flux> zip(Publisher source1, * * @return a zipped {@link Flux} */ - public static Flux> zip(Publisher source1, - Publisher source2, - Publisher source3) { + public static Flux<@NonNull Tuple3<@NonNull T1, @NonNull T2, @NonNull T3>> zip(Publisher source1, + Publisher source2, + Publisher source3) { return zip(Tuples.fn3(), source1, source2, source3); } @@ -1602,10 +1603,10 @@ public static Flux> zip(Publisher * * @return a zipped {@link Flux} */ - public static Flux> zip(Publisher source1, - Publisher source2, - Publisher source3, - Publisher source4) { + public static Flux<@NonNull Tuple4<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4>> zip(Publisher source1, + Publisher source2, + Publisher source3, + Publisher source4) { return zip(Tuples.fn4(), source1, source2, source3, source4); } @@ -1631,11 +1632,11 @@ public static Flux> zip(Publisher Flux> zip(Publisher source1, - Publisher source2, - Publisher source3, - Publisher source4, - Publisher source5) { + public static Flux<@NonNull Tuple5<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4, @NonNull T5>> zip(Publisher source1, + Publisher source2, + Publisher source3, + Publisher source4, + Publisher source5) { return zip(Tuples.fn5(), source1, source2, source3, source4, source5); } @@ -1663,12 +1664,12 @@ public static Flux> zip(Publishe * * @return a zipped {@link Flux} */ - public static Flux> zip(Publisher source1, - Publisher source2, - Publisher source3, - Publisher source4, - Publisher source5, - Publisher source6) { + public static Flux<@NonNull Tuple6<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4, @NonNull T5, @NonNull T6>> zip(Publisher source1, + Publisher source2, + Publisher source3, + Publisher source4, + Publisher source5, + Publisher source6) { return zip(Tuples.fn6(), source1, source2, source3, source4, source5, source6); } @@ -1692,8 +1693,8 @@ public static Flux> zip( * * @return a zipped {@link Flux} */ - public static Flux zip(Iterable> sources, - final Function combinator) { + public static Flux<@NonNull O> zip(Iterable> sources, + final Function combinator) { return zip(sources, Queues.XS_BUFFER_SIZE, combinator); } @@ -1719,9 +1720,9 @@ public static Flux zip(Iterable> sources, * * @return a zipped {@link Flux} */ - public static Flux zip(Iterable> sources, + public static Flux<@NonNull O> zip(Iterable> sources, int prefetch, - final Function combinator) { + final Function combinator) { return onAssembly(new FluxZip(sources, combinator, @@ -1748,8 +1749,8 @@ public static Flux zip(Iterable> sources, * @return a zipped {@link Flux} */ @SafeVarargs - public static Flux zip( - final Function combinator, Publisher... sources) { + public static Flux<@NonNull O> zip( + final Function combinator, Publisher @NonNull ... sources) { return zip(combinator, Queues.XS_BUFFER_SIZE, sources); } @@ -1773,9 +1774,9 @@ public static Flux zip( * @return a zipped {@link Flux} */ @SafeVarargs - public static Flux zip(final Function combinator, + public static Flux<@NonNull O> zip(final Function combinator, int prefetch, - Publisher... sources) { + Publisher @NonNull ... sources) { if (sources.length == 0) { return empty(); @@ -1819,9 +1820,9 @@ public static Flux zip(final Function c * @return a {@link Flux} based on the produced value */ @SuppressWarnings({ "rawtypes", "unchecked" }) - public static Flux zip(Publisher> sources, - final Function combinator) { + public static Flux<@NonNull V> zip(Publisher> sources, + final Function combinator) { return onAssembly(new FluxBuffer<>(from(sources), Integer.MAX_VALUE, listSupplier()) .flatMap(new Function>, Publisher>() { @@ -1850,7 +1851,7 @@ public Publisher apply(List> publishers) { * @return a new {@link Mono} with true if all values satisfies a predicate and false * otherwise */ - public final Mono all(Predicate predicate) { + public final Mono all(Predicate predicate) { return Mono.onAssembly(new MonoAll<>(this, predicate)); } @@ -1869,7 +1870,7 @@ public final Mono all(Predicate predicate) { * @return a new {@link Mono} with true if any value satisfies a predicate and false * otherwise */ - public final Mono any(Predicate predicate) { + public final Mono any(Predicate predicate) { return Mono.onAssembly(new MonoAny<>(this, predicate)); } @@ -1886,7 +1887,7 @@ public final Mono any(Predicate predicate) { * @return the {@link Flux} transformed to an instance of P * @see #compose for a bounded conversion to {@link Publisher} */ - public final

P as(Function, P> transformer) { + public final

P as(Function, @NonNull P> transformer) { return transformer.apply(this); } @@ -1979,7 +1980,7 @@ public final T blockLast(Duration timeout) { * @return a buffered {@link Flux} of at most one {@link List} * @see #collectList() for an alternative collecting algorithm returning {@link Mono} */ - public final Flux> buffer() { + public final Flux<@NonNull List<@NonNull T>> buffer() { return buffer(Integer.MAX_VALUE); } @@ -1995,7 +1996,7 @@ public final Flux> buffer() { * * @return a microbatched {@link Flux} of {@link List} */ - public final Flux> buffer(int maxSize) { + public final Flux<@NonNull List<@NonNull T>> buffer(int maxSize) { return buffer(maxSize, listSupplier()); } @@ -2013,7 +2014,7 @@ public final Flux> buffer(int maxSize) { * * @return a microbatched {@link Flux} of {@link Collection} */ - public final > Flux buffer(int maxSize, Supplier bufferSupplier) { + public final > Flux<@NonNull C> buffer(int maxSize, Supplier<@NonNull C> bufferSupplier) { return onAssembly(new FluxBuffer<>(this, maxSize, bufferSupplier)); } @@ -2043,7 +2044,7 @@ public final > Flux buffer(int maxSize, Suppl * * @return a microbatched {@link Flux} of possibly overlapped or gapped {@link List} */ - public final Flux> buffer(int maxSize, int skip) { + public final Flux<@NonNull List<@NonNull T>> buffer(int maxSize, int skip) { return buffer(maxSize, skip, listSupplier()); } @@ -2076,8 +2077,8 @@ public final Flux> buffer(int maxSize, int skip) { * @return a microbatched {@link Flux} of possibly overlapped or gapped * {@link Collection} */ - public final > Flux buffer(int maxSize, - int skip, Supplier bufferSupplier) { + public final > Flux<@NonNull C> buffer(int maxSize, + int skip, Supplier<@NonNull C> bufferSupplier) { return onAssembly(new FluxBuffer<>(this, maxSize, skip, bufferSupplier)); } @@ -2092,7 +2093,7 @@ public final > Flux buffer(int maxSize, * * @return a microbatched {@link Flux} of {@link List} delimited by signals from a {@link Publisher} */ - public final Flux> buffer(Publisher other) { + public final Flux<@NonNull List<@NonNull T>> buffer(Publisher other) { return buffer(other, listSupplier()); } @@ -2110,7 +2111,7 @@ public final Flux> buffer(Publisher other) { * * @return a microbatched {@link Flux} of {@link Collection} delimited by signals from a {@link Publisher} */ - public final > Flux buffer(Publisher other, Supplier bufferSupplier) { + public final > Flux<@NonNull C> buffer(Publisher<@NonNull ?> other, Supplier<@NonNull C> bufferSupplier) { return onAssembly(new FluxBufferBoundary<>(this, other, bufferSupplier)); } @@ -2125,7 +2126,7 @@ public final > Flux buffer(Publisher other * * @return a microbatched {@link Flux} of {@link List} delimited by the given time span */ - public final Flux> buffer(Duration timespan) { + public final Flux<@NonNull List<@NonNull T>> buffer(Duration timespan) { return buffer(timespan, Schedulers.parallel()); } @@ -2154,7 +2155,7 @@ public final Flux> buffer(Duration timespan) { * * @return a microbatched {@link Flux} of {@link List} delimited by the given period timeshift and sized by timespan */ - public final Flux> buffer(Duration timespan, Duration timeshift) { + public final Flux<@NonNull List<@NonNull T>> buffer(Duration timespan, Duration timeshift) { return buffer(timespan, timeshift, Schedulers.parallel()); } @@ -2170,7 +2171,7 @@ public final Flux> buffer(Duration timespan, Duration timeshift) { * * @return a microbatched {@link Flux} of {@link List} delimited by the given period */ - public final Flux> buffer(Duration timespan, Scheduler timer) { + public final Flux<@NonNull List<@NonNull T>> buffer(Duration timespan, Scheduler timer) { return buffer(interval(timespan, timer)); } @@ -2201,7 +2202,7 @@ public final Flux> buffer(Duration timespan, Scheduler timer) { * * @return a microbatched {@link Flux} of {@link List} delimited by the given period timeshift and sized by timespan */ - public final Flux> buffer(Duration timespan, Duration timeshift, Scheduler timer) { + public final Flux<@NonNull List<@NonNull T>> buffer(Duration timespan, Duration timeshift, Scheduler timer) { if (timespan.equals(timeshift)) { return buffer(timespan, timer); } @@ -2222,7 +2223,7 @@ public final Flux> buffer(Duration timespan, Duration timeshift, Schedul * * @return a microbatched {@link Flux} of {@link List} delimited by given size or a given period timeout */ - public final Flux> bufferTimeout(int maxSize, Duration timespan) { + public final Flux<@NonNull List<@NonNull T>> bufferTimeout(int maxSize, Duration timespan) { return bufferTimeout(maxSize, timespan, listSupplier()); } @@ -2240,7 +2241,7 @@ public final Flux> bufferTimeout(int maxSize, Duration timespan) { * @param the {@link Collection} buffer type * @return a microbatched {@link Flux} of {@link Collection} delimited by given size or a given period timeout */ - public final > Flux bufferTimeout(int maxSize, Duration timespan, Supplier bufferSupplier) { + public final > Flux<@NonNull C> bufferTimeout(int maxSize, Duration timespan, Supplier<@NonNull C> bufferSupplier) { return bufferTimeout(maxSize, timespan, Schedulers.parallel(), bufferSupplier); } @@ -2259,7 +2260,7 @@ public final > Flux bufferTimeout(int maxSize * * @return a microbatched {@link Flux} of {@link List} delimited by given size or a given period timeout */ - public final Flux> bufferTimeout(int maxSize, Duration timespan, Scheduler timer) { + public final Flux<@NonNull List<@NonNull T>> bufferTimeout(int maxSize, Duration timespan, Scheduler timer) { return bufferTimeout(maxSize, timespan, timer, listSupplier()); } @@ -2278,8 +2279,8 @@ public final Flux> bufferTimeout(int maxSize, Duration timespan, Schedul * @param the {@link Collection} buffer type * @return a microbatched {@link Flux} of {@link Collection} delimited by given size or a given period timeout */ - public final > Flux bufferTimeout(int maxSize, Duration timespan, - Scheduler timer, Supplier bufferSupplier) { + public final > Flux<@NonNull C> bufferTimeout(int maxSize, Duration timespan, + Scheduler timer, Supplier<@NonNull C> bufferSupplier) { return onAssembly(new FluxBufferTimeOrSize<>(this, maxSize, timespan.toMillis(), timer, bufferSupplier)); } @@ -2299,7 +2300,7 @@ public final > Flux bufferTimeout(int maxSiz * @param predicate a predicate that triggers the next buffer when it becomes true. * @return a microbatched {@link Flux} of {@link List} */ - public final Flux> bufferUntil(Predicate predicate) { + public final Flux<@NonNull List<@NonNull T>> bufferUntil(Predicate predicate) { return onAssembly(new FluxBufferPredicate<>(this, predicate, listSupplier(), FluxBufferPredicate.Mode.UNTIL)); } @@ -2323,7 +2324,7 @@ public final Flux> bufferUntil(Predicate predicate) { * @param cutBefore push to true to include the triggering element in the new buffer rather than the old. * @return a microbatched {@link Flux} of {@link List} */ - public final Flux> bufferUntil(Predicate predicate, boolean cutBefore) { + public final Flux<@NonNull List<@NonNull T>> bufferUntil(Predicate predicate, boolean cutBefore) { return onAssembly(new FluxBufferPredicate<>(this, predicate, listSupplier(), cutBefore ? FluxBufferPredicate.Mode.UNTIL_CUT_BEFORE : FluxBufferPredicate.Mode.UNTIL)); @@ -2333,7 +2334,7 @@ public final Flux> bufferUntil(Predicate predicate, boolean c * Collect incoming values into multiple {@link List} buffers that will be emitted by * the resulting {@link Flux}. Each buffer continues aggregating values while the * given predicate returns true, and a new buffer is created as soon as the - * predicate returns false... Note that the element that triggers the predicate + * predicate returns false ... Note that the element that triggers the predicate * to return false (and thus closes a buffer) is NOT included in any emitted buffer. *

* > bufferUntil(Predicate predicate, boolean c * @param predicate a predicate that triggers the next buffer when it becomes false. * @return a microbatched {@link Flux} of {@link List} */ - public final Flux> bufferWhile(Predicate predicate) { + public final Flux<@NonNull List<@NonNull T>> bufferWhile(Predicate predicate) { return onAssembly(new FluxBufferPredicate<>(this, predicate, listSupplier(), FluxBufferPredicate.Mode.WHILE)); } @@ -2380,7 +2381,7 @@ public final Flux> bufferWhile(Predicate predicate) { * @return a microbatched {@link Flux} of {@link List} delimited by an opening {@link Publisher} and a relative * closing {@link Publisher} */ - public final Flux> bufferWhen(Publisher bucketOpening, + public final Flux<@NonNull List<@NonNull T>> bufferWhen(Publisher<@NonNull U> bucketOpening, Function> closeSelector) { return bufferWhen(bucketOpening, closeSelector, listSupplier()); } @@ -2416,8 +2417,8 @@ public final Flux> bufferWhen(Publisher bucketOpening, * @return a microbatched {@link Flux} of {@link Collection} delimited by an opening {@link Publisher} and a relative * closing {@link Publisher} */ - public final > Flux bufferWhen(Publisher bucketOpening, - Function> closeSelector, Supplier bufferSupplier) { + public final > Flux<@NonNull C> bufferWhen(Publisher<@NonNull U> bucketOpening, + Function> closeSelector, Supplier<@NonNull C> bufferSupplier) { return onAssembly(new FluxBufferWhen<>(this, bucketOpening, closeSelector, bufferSupplier, Queues.unbounded(Queues.XS_BUFFER_SIZE))); } @@ -2432,7 +2433,7 @@ public final > Flux bufferWhen(Publishe * * @return a replaying {@link Flux} */ - public final Flux cache() { + public final Flux<@NonNull T> cache() { return cache(Integer.MAX_VALUE); } @@ -2451,7 +2452,7 @@ public final Flux cache() { * @return a replaying {@link Flux} * */ - public final Flux cache(int history) { + public final Flux<@NonNull T> cache(int history) { return replay(history).autoConnect(); } @@ -2469,7 +2470,7 @@ public final Flux cache(int history) { * * @return a replaying {@link Flux} */ - public final Flux cache(Duration ttl) { + public final Flux<@NonNull T> cache(Duration ttl) { return replay(Integer.MAX_VALUE, ttl).autoConnect(); } @@ -2489,7 +2490,7 @@ public final Flux cache(Duration ttl) { * * @return a replaying {@link Flux} */ - public final Flux cache(int history, Duration ttl) { + public final Flux<@NonNull T> cache(int history, Duration ttl) { return replay(history, ttl).autoConnect(); } @@ -2504,7 +2505,7 @@ public final Flux cache(int history, Duration ttl) { * * @return a casted {@link Flux} */ - public final Flux cast(Class clazz) { + public final Flux<@NonNull E> cast(Class clazz) { Objects.requireNonNull(clazz, "clazz"); return map(clazz::cast); } @@ -2518,7 +2519,7 @@ public final Flux cast(Class clazz) { * * @return a scheduled cancel {@link Flux} */ - public final Flux cancelOn(Scheduler scheduler) { + public final Flux<@NonNull T> cancelOn(Scheduler scheduler) { return onAssembly(new FluxCancelOn<>(this, scheduler)); } @@ -2532,7 +2533,7 @@ public final Flux cancelOn(Scheduler scheduler) { * * @return the assembly tracing {@link Flux}. */ - public final Flux checkpoint() { + public final Flux<@NonNull T> checkpoint() { return checkpoint(null, true); } @@ -2552,7 +2553,7 @@ public final Flux checkpoint() { * @param description a unique enough description to include in the light assembly traceback. * @return the assembly marked {@link Flux} */ - public final Flux checkpoint(String description) { + public final Flux<@NonNull T> checkpoint(String description) { return checkpoint(Objects.requireNonNull(description), false); } @@ -2582,7 +2583,7 @@ public final Flux checkpoint(String description) { * to use a stack trace. * @return the assembly marked {@link Flux}. */ - public final Flux checkpoint(@Nullable String description, boolean forceStackTrace) { + public final Flux<@NonNull T> checkpoint(@Nullable String description, boolean forceStackTrace) { return new FluxOnAssembly<>(this, description, !forceStackTrace); } @@ -2601,7 +2602,7 @@ public final Flux checkpoint(@Nullable String description, boolean forceStack * @return a {@link Mono} of the collected container on complete * */ - public final Mono collect(Supplier containerSupplier, BiConsumer collector) { + public final Mono<@NonNull E> collect(Supplier<@NonNull E> containerSupplier, BiConsumer<@NonNull E, ? super @NonNull T> collector) { return Mono.onAssembly(new MonoCollect<>(this, containerSupplier, collector)); } @@ -2620,7 +2621,7 @@ public final Mono collect(Supplier containerSupplier, BiConsumer Mono collect(Collector collector) { + public final Mono<@NonNull R> collect(Collector collector) { return Mono.onAssembly(new MonoStreamCollector<>(this, collector)); } @@ -2633,7 +2634,7 @@ public final Mono collect(Collector collect * * @return a {@link Mono} of a {@link List} of all values from this {@link Flux} */ - public final Mono> collectList() { + public final Mono<@NonNull List<@NonNull T>> collectList() { if (this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { @SuppressWarnings("unchecked") @@ -2684,7 +2685,7 @@ public final Mono> collectList() { * element in case of key conflicts) * */ - public final Mono> collectMap(Function keyExtractor) { + public final Mono<@NonNull Map<@NonNull K, @NonNull T>> collectMap(Function keyExtractor) { return collectMap(keyExtractor, identityFunction()); } @@ -2708,8 +2709,8 @@ public final Mono> collectMap(Function key * @return a {@link Mono} of a {@link Map} of key-element pairs (only including latest * element's value in case of key conflicts) */ - public final Mono> collectMap(Function keyExtractor, - Function valueExtractor) { + public final Mono<@NonNull Map<@NonNull K, @NonNull V>> collectMap(Function keyExtractor, + Function valueExtractor) { return collectMap(keyExtractor, valueExtractor, () -> new HashMap<>()); } @@ -2734,10 +2735,10 @@ public final Mono> collectMap(Function * @return a {@link Mono} of a {@link Map} of key-value pairs (only including latest * element's value in case of key conflicts) */ - public final Mono> collectMap( - final Function keyExtractor, - final Function valueExtractor, - Supplier> mapSupplier) { + public final Mono<@NonNull Map<@NonNull K, @NonNull V>> collectMap( + final Function keyExtractor, + final Function valueExtractor, + Supplier<@NonNull Map<@NonNull K, @NonNull V>> mapSupplier) { Objects.requireNonNull(keyExtractor, "Key extractor is null"); Objects.requireNonNull(valueExtractor, "Value extractor is null"); Objects.requireNonNull(mapSupplier, "Map supplier is null"); @@ -2759,7 +2760,7 @@ public final Mono> collectMap( * @param the type of the key extracted from each source element * @return a {@link Mono} of a {@link Map} of key-List(elements) pairs */ - public final Mono>> collectMultimap(Function keyExtractor) { + public final Mono<@NonNull Map<@NonNull K, @NonNull Collection<@NonNull T>>> collectMultimap(Function keyExtractor) { return collectMultimap(keyExtractor, identityFunction()); } @@ -2782,8 +2783,8 @@ public final Mono>> collectMultimap(Function Mono>> collectMultimap(Function keyExtractor, - Function valueExtractor) { + public final Mono<@NonNull Map<@NonNull K, @NonNull Collection<@NonNull V>>> collectMultimap(Function keyExtractor, + Function valueExtractor) { return collectMultimap(keyExtractor, valueExtractor, () -> new HashMap<>()); } @@ -2809,9 +2810,9 @@ public final Mono>> collectMultimap(Function Mono>> collectMultimap( - final Function keyExtractor, - final Function valueExtractor, + public final Mono<@NonNull Map<@NonNull K, @NonNull Collection<@NonNull V>>> collectMultimap( + final Function keyExtractor, + final Function valueExtractor, Supplier>> mapSupplier) { Objects.requireNonNull(keyExtractor, "Key extractor is null"); Objects.requireNonNull(valueExtractor, "Value extractor is null"); @@ -2833,7 +2834,7 @@ public final Mono>> collectMultimap( * * @return a {@link Mono} of a sorted {@link List} of all values from this {@link Flux}, in natural order */ - public final Mono> collectSortedList() { + public final Mono<@NonNull List<@NonNull T>> collectSortedList() { return collectSortedList(null); } @@ -2850,7 +2851,7 @@ public final Mono> collectSortedList() { * @return a {@link Mono} of a sorted {@link List} of all values from this {@link Flux} */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public final Mono> collectSortedList(@Nullable Comparator comparator) { + public final Mono<@NonNull List<@NonNull T>> collectSortedList(@Nullable Comparator comparator) { return collectList().map(list -> { // Note: this assumes the list emitted by buffer() is mutable if (comparator != null) { @@ -2879,7 +2880,7 @@ public final Mono> collectSortedList(@Nullable Comparator com * @see #transform transform() for immmediate transformation of {@link Flux} * @see #as as() for a loose conversion to an arbitrary type */ - public final Flux compose(Function, ? extends Publisher> transformer) { + public final Flux<@NonNull V> compose(Function, ? extends @NonNull Publisher<@NonNull V>> transformer) { return defer(() -> transformer.apply(this)); } @@ -2911,7 +2912,7 @@ public final Flux compose(Function, ? extends Publisher Flux concatMap(Function> + public final Flux<@NonNull V> concatMap(Function> mapper) { return concatMap(mapper, Queues.XS_BUFFER_SIZE); } @@ -2946,7 +2947,7 @@ public final Flux concatMap(Function Flux concatMap(Function> + public final Flux<@NonNull V> concatMap(Function> mapper, int prefetch) { return onAssembly(new FluxConcatMap<>(this, mapper, Queues.get(prefetch), prefetch, FluxConcatMap.ErrorMode.IMMEDIATE)); @@ -2982,7 +2983,7 @@ public final Flux concatMap(Function Flux concatMapDelayError(Function> mapper) { + public final Flux<@NonNull V> concatMapDelayError(Function> mapper) { return concatMapDelayError(mapper, Queues.XS_BUFFER_SIZE); } @@ -3018,8 +3019,8 @@ public final Flux concatMapDelayError(Function Flux concatMapDelayError(Function> mapper, int prefetch) { + public final Flux<@NonNull V> concatMapDelayError(Function> mapper, int prefetch) { return onAssembly(new FluxConcatMap<>(this, mapper, Queues.get(prefetch), prefetch, FluxConcatMap.ErrorMode.BOUNDARY)); } @@ -3059,8 +3060,8 @@ public final Flux concatMapDelayError(Function Flux concatMapDelayError(Function> mapper, boolean delayUntilEnd, int prefetch) { + public final Flux<@NonNull V> concatMapDelayError(Function> mapper, boolean delayUntilEnd, int prefetch) { return onAssembly(new FluxConcatMap<>(this, mapper, Queues.get(prefetch), prefetch, delayUntilEnd ? FluxConcatMap.ErrorMode.END : FluxConcatMap.ErrorMode .BOUNDARY)); @@ -3083,7 +3084,7 @@ public final Flux concatMapDelayError(Function Flux concatMapIterable(Function> mapper) { + public final Flux<@NonNull R> concatMapIterable(Function> mapper) { return concatMapIterable(mapper, Queues.XS_BUFFER_SIZE); } @@ -3105,7 +3106,7 @@ public final Flux concatMapIterable(Function Flux concatMapIterable(Function> mapper, + public final Flux<@NonNull R> concatMapIterable(Function> mapper, int prefetch) { return onAssembly(new FluxFlattenIterable<>(this, mapper, prefetch, Queues.get(prefetch))); @@ -3121,7 +3122,7 @@ public final Flux concatMapIterable(Function concatWith(Publisher other) { + public final Flux<@NonNull T> concatWith(Publisher other) { if (this instanceof FluxConcatArray) { @SuppressWarnings({ "unchecked" }) FluxConcatArray fluxConcatArray = (FluxConcatArray) this; @@ -3140,7 +3141,7 @@ public final Flux concatWith(Publisher other) { * * @return a new {@link Mono} of {@link Long} count */ - public final Mono count() { + public final Mono<@NonNull Long> count() { return Mono.onAssembly(new MonoCount<>(this)); } @@ -3153,7 +3154,7 @@ public final Mono count() { * * @return a new {@link Flux} */ - public final Flux defaultIfEmpty(T defaultV) { + public final Flux<@NonNull T> defaultIfEmpty(T defaultV) { return onAssembly(new FluxDefaultIfEmpty<>(this, defaultV)); } @@ -3170,7 +3171,7 @@ public final Flux defaultIfEmpty(T defaultV) { * @return a delayed {@link Flux} * @see #delaySubscription(Duration) delaySubscription to introduce a delay at the beginning of the sequence only */ - public final Flux delayElements(Duration delay) { + public final Flux<@NonNull T> delayElements(Duration delay) { return delayElements(delay, Schedulers.parallel()); } @@ -3186,7 +3187,7 @@ public final Flux delayElements(Duration delay) { * @param timer a time-capable {@link Scheduler} instance to delay each signal on * @return a delayed {@link Flux} */ - public final Flux delayElements(Duration delay, Scheduler timer) { + public final Flux<@NonNull T> delayElements(Duration delay, Scheduler timer) { return delayUntil(d -> Mono.delay(delay, timer)); } @@ -3209,7 +3210,7 @@ public final Flux delayElements(Duration delay, Scheduler timer) { * * @return this Flux, but with elements delayed until their derived publisher terminates. */ - public final Flux delayUntil(Function> triggerProvider) { + public final Flux<@NonNull T> delayUntil(Function> triggerProvider) { return concatMap(v -> Mono.just(v) .delayUntil(triggerProvider)); } @@ -3227,7 +3228,7 @@ public final Flux delayUntil(Function> trig * @return a delayed {@link Flux} * */ - public final Flux delaySubscription(Duration delay) { + public final Flux<@NonNull T> delaySubscription(Duration delay) { return delaySubscription(delay, Schedulers.parallel()); } @@ -3243,7 +3244,7 @@ public final Flux delaySubscription(Duration delay) { * * @return a delayed {@link Flux} */ - public final Flux delaySubscription(Duration delay, Scheduler timer) { + public final Flux<@NonNull T> delaySubscription(Duration delay, Scheduler timer) { return delaySubscription(Mono.delay(delay, timer)); } @@ -3260,7 +3261,7 @@ public final Flux delaySubscription(Duration delay, Scheduler timer) { * @return a delayed {@link Flux} * */ - public final Flux delaySubscription(Publisher subscriptionDelay) { + public final Flux<@NonNull T> delaySubscription(Publisher<@NonNull U> subscriptionDelay) { return onAssembly(new FluxDelaySubscription<>(this, subscriptionDelay)); } @@ -3279,7 +3280,7 @@ public final Flux delaySubscription(Publisher subscriptionDelay) { * @return a dematerialized {@link Flux} * @see #materialize() */ - public final Flux dematerialize() { + public final Flux<@NonNull X> dematerialize() { @SuppressWarnings("unchecked") Flux> thiz = (Flux>) this; return onAssembly(new FluxDematerialize<>(thiz)); @@ -3294,7 +3295,7 @@ public final Flux dematerialize() { * * @return a filtering {@link Flux} only emitting distinct values */ - public final Flux distinct() { + public final Flux<@NonNull T> distinct() { return distinct(hashcodeSupplier()); } @@ -3311,7 +3312,7 @@ public final Flux distinct() { * * @return a filtering {@link Flux} only emitting values with distinct keys */ - public final Flux distinct(Function keySelector) { + public final Flux<@NonNull T> distinct(Function keySelector) { return distinct(keySelector, hashSetSupplier()); } @@ -3333,9 +3334,9 @@ public final Flux distinct(Function keySelector) * * @return a filtering {@link Flux} only emitting values with distinct keys */ - public final > Flux distinct( - Function keySelector, - Supplier distinctCollectionSupplier) { + public final > Flux<@NonNull T> distinct( + Function keySelector, + Supplier<@NonNull C> distinctCollectionSupplier) { if (this instanceof Fuseable) { return onAssembly(new FluxDistinctFuseable<>(this, keySelector, distinctCollectionSupplier)); @@ -3353,7 +3354,7 @@ public final > Flux distinct( * @return a filtering {@link Flux} with only one occurrence in a row of each element * (yet elements can repeat in the overall sequence) */ - public final Flux distinctUntilChanged() { + public final Flux<@NonNull T> distinctUntilChanged() { return distinctUntilChanged(hashcodeSupplier()); } @@ -3372,7 +3373,7 @@ public final Flux distinctUntilChanged() { * @return a filtering {@link Flux} with only one occurrence in a row of each element of * the same key (yet element keys can repeat in the overall sequence) */ - public final Flux distinctUntilChanged(Function keySelector) { + public final Flux<@NonNull T> distinctUntilChanged(Function keySelector) { return distinctUntilChanged(keySelector, equalPredicate()); } @@ -3392,8 +3393,8 @@ public final Flux distinctUntilChanged(Function k * of the same key for which the predicate returns true (yet element keys can repeat * in the overall sequence) */ - public final Flux distinctUntilChanged(Function keySelector, - BiPredicate keyComparator) { + public final Flux<@NonNull T> distinctUntilChanged(Function keySelector, + BiPredicate keyComparator) { return onAssembly(new FluxDistinctUntilChanged<>(this, keySelector, keyComparator)); @@ -3408,7 +3409,7 @@ public final Flux distinctUntilChanged(Function k * * @return an observed {@link Flux} */ - public final Flux doAfterTerminate(Runnable afterTerminate) { + public final Flux<@NonNull T> doAfterTerminate(Runnable afterTerminate) { Objects.requireNonNull(afterTerminate, "afterTerminate"); return doOnSignal(this, null, null, null, null, afterTerminate, null, null); } @@ -3422,7 +3423,7 @@ public final Flux doAfterTerminate(Runnable afterTerminate) { * * @return an observed {@link Flux} */ - public final Flux doOnCancel(Runnable onCancel) { + public final Flux<@NonNull T> doOnCancel(Runnable onCancel) { Objects.requireNonNull(onCancel, "onCancel"); return doOnSignal(this, null, null, null, null, null, null, onCancel); } @@ -3436,7 +3437,7 @@ public final Flux doOnCancel(Runnable onCancel) { * * @return an observed {@link Flux} */ - public final Flux doOnComplete(Runnable onComplete) { + public final Flux<@NonNull T> doOnComplete(Runnable onComplete) { Objects.requireNonNull(onComplete, "onComplete"); return doOnSignal(this, null, null, null, onComplete, null, null, null); } @@ -3457,7 +3458,7 @@ public final Flux doOnComplete(Runnable onComplete) { * @see #materialize() * @see Signal */ - public final Flux doOnEach(Consumer> signalConsumer) { + public final Flux<@NonNull T> doOnEach(Consumer> signalConsumer) { return onAssembly(new FluxDoOnEach<>(this, signalConsumer)); } @@ -3470,7 +3471,7 @@ public final Flux doOnEach(Consumer> signalConsumer) { * * @return an observed {@link Flux} */ - public final Flux doOnError(Consumer onError) { + public final Flux<@NonNull T> doOnError(Consumer onError) { Objects.requireNonNull(onError, "onError"); return doOnSignal(this, null, null, onError, null, null, null, null); } @@ -3487,8 +3488,8 @@ public final Flux doOnError(Consumer onError) { * @return an observed {@link Flux} * */ - public final Flux doOnError(Class exceptionType, - final Consumer onError) { + public final Flux<@NonNull T> doOnError(Class exceptionType, + final Consumer onError) { Objects.requireNonNull(exceptionType, "type"); @SuppressWarnings("unchecked") Consumer handler = (Consumer)onError; @@ -3506,8 +3507,8 @@ public final Flux doOnError(Class exceptionType, * @return an observed {@link Flux} * */ - public final Flux doOnError(Predicate predicate, - final Consumer onError) { + public final Flux<@NonNull T> doOnError(Predicate predicate, + final Consumer onError) { Objects.requireNonNull(predicate, "predicate"); return doOnError(t -> { if (predicate.test(t)) { @@ -3525,7 +3526,7 @@ public final Flux doOnError(Predicate predicate, * * @return an observed {@link Flux} */ - public final Flux doOnNext(Consumer onNext) { + public final Flux<@NonNull T> doOnNext(Consumer onNext) { Objects.requireNonNull(onNext, "onNext"); return doOnSignal(this, null, onNext, null, null, null, null, null); } @@ -3544,7 +3545,7 @@ public final Flux doOnNext(Consumer onNext) { * * @return an observed {@link Flux} */ - public final Flux doOnRequest(LongConsumer consumer) { + public final Flux<@NonNull T> doOnRequest(LongConsumer consumer) { Objects.requireNonNull(consumer, "consumer"); return doOnSignal(this, null, null, null, null, null, consumer, null); } @@ -3558,7 +3559,7 @@ public final Flux doOnRequest(LongConsumer consumer) { * * @return an observed {@link Flux} */ - public final Flux doOnSubscribe(Consumer onSubscribe) { + public final Flux<@NonNull T> doOnSubscribe(Consumer onSubscribe) { Objects.requireNonNull(onSubscribe, "onSubscribe"); return doOnSignal(this, onSubscribe, null, null, null, null, null, null); } @@ -3573,7 +3574,7 @@ public final Flux doOnSubscribe(Consumer onSubscribe) { * * @return an observed {@link Flux} */ - public final Flux doOnTerminate(Runnable onTerminate) { + public final Flux<@NonNull T> doOnTerminate(Runnable onTerminate) { Objects.requireNonNull(onTerminate, "onTerminate"); return doOnSignal(this, null, @@ -3601,7 +3602,7 @@ public final Flux doOnTerminate(Runnable onTerminate) { * or cancel) * @return an observed {@link Flux} */ - public final Flux doFinally(Consumer onFinally) { + public final Flux<@NonNull T> doFinally(Consumer<@NonNull SignalType> onFinally) { Objects.requireNonNull(onFinally, "onFinally"); if (this instanceof Fuseable) { return onAssembly(new FluxDoFinallyFuseable<>(this, onFinally)); @@ -3620,7 +3621,7 @@ public final Flux doFinally(Consumer onFinally) { * * @return a new {@link Flux} that emits a tuple of time elapsed in milliseconds and matching data */ - public final Flux> elapsed() { + public final Flux<@NonNull Tuple2<@NonNull Long, @NonNull T>> elapsed() { return elapsed(Schedulers.parallel()); } @@ -3637,7 +3638,7 @@ public final Flux> elapsed() { * * @return a new {@link Flux} that emits tuples of time elapsed in milliseconds and matching data */ - public final Flux> elapsed(Scheduler scheduler) { + public final Flux<@NonNull Tuple2<@NonNull Long, @NonNull T>> elapsed(Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler"); return onAssembly(new FluxElapsed<>(this, scheduler)); } @@ -3653,7 +3654,7 @@ public final Flux> elapsed(Scheduler scheduler) { * * @return a {@link Mono} of the item at the specified zero-based index */ - public final Mono elementAt(int index) { + public final Mono<@NonNull T> elementAt(int index) { return Mono.onAssembly(new MonoElementAt<>(this, index)); } @@ -3669,7 +3670,7 @@ public final Mono elementAt(int index) { * * @return a {@link Mono} of the item at the specified zero-based index or a default value */ - public final Mono elementAt(int index, T defaultValue) { + public final Mono<@NonNull T> elementAt(int index, T defaultValue) { return Mono.onAssembly(new MonoElementAt<>(this, index, defaultValue)); } @@ -3838,7 +3839,7 @@ public final Flux expand(Function * * @return a new {@link Flux} containing only values that pass the predicate test */ - public final Flux filter(Predicate p) { + public final Flux<@NonNull T> filter(Predicate p) { if (this instanceof Fuseable) { return onAssembly(new FluxFilterFuseable<>(this, p)); } @@ -3859,7 +3860,7 @@ public final Flux filter(Predicate p) { * for each value, to filter the Flux with * @return a filtered {@link Flux} */ - public final Flux filterWhen(Function> asyncPredicate) { + public final Flux<@NonNull T> filterWhen(Function> asyncPredicate) { return filterWhen(asyncPredicate, Queues.SMALL_BUFFER_SIZE); } @@ -3882,7 +3883,7 @@ public final Flux filterWhen(Function * the initial request size for the source. * @return a filtered {@link Flux} */ - public final Flux filterWhen(Function> asyncPredicate, + public final Flux<@NonNull T> filterWhen(Function> asyncPredicate, int bufferSize) { return onAssembly(new FluxFilterWhen<>(this, asyncPredicate, bufferSize)); } @@ -3910,7 +3911,7 @@ public final Flux filterWhen(Function * * @return a new {@link Flux} */ - public final Flux flatMap(Function> mapper) { + public final Flux<@NonNull R> flatMap(Function> mapper) { return flatMap(mapper, Queues.SMALL_BUFFER_SIZE, Queues .XS_BUFFER_SIZE); } @@ -3942,7 +3943,7 @@ public final Flux flatMap(Function Flux flatMap(Function> mapper, int + public final Flux<@NonNull V> flatMap(Function> mapper, int concurrency) { return flatMap(mapper, concurrency, Queues.XS_BUFFER_SIZE); } @@ -3976,7 +3977,7 @@ public final Flux flatMap(Function Flux flatMap(Function> mapper, int + public final Flux<@NonNull V> flatMap(Function> mapper, int concurrency, int prefetch) { return flatMap(mapper, false, concurrency, prefetch); } @@ -4011,7 +4012,7 @@ public final Flux flatMap(Function Flux flatMapDelayError(Function> mapper, + public final Flux<@NonNull V> flatMapDelayError(Function> mapper, int concurrency, int prefetch) { return flatMap(mapper, true, concurrency, prefetch); } @@ -4047,10 +4048,10 @@ public final Flux flatMapDelayError(Function Flux flatMap( - @Nullable Function> mapperOnNext, - @Nullable Function> mapperOnError, - @Nullable Supplier> mapperOnComplete) { + public final Flux<@NonNull R> flatMap( + @Nullable Function> mapperOnNext, + @Nullable Function> mapperOnError, + @Nullable Supplier> mapperOnComplete) { return onAssembly(new FluxFlatMap<>( new FluxMapSignal<>(this, mapperOnNext, mapperOnError, mapperOnComplete), identityFunction(), @@ -4077,7 +4078,7 @@ public final Flux flatMap( * * @return a concatenation of the values from the Iterables obtained from each element in this {@link Flux} */ - public final Flux flatMapIterable(Function> mapper) { + public final Flux<@NonNull R> flatMapIterable(Function> mapper) { return flatMapIterable(mapper, Queues.SMALL_BUFFER_SIZE); } @@ -4100,7 +4101,7 @@ public final Flux flatMapIterable(Function Flux flatMapIterable(Function> mapper, int prefetch) { + public final Flux<@NonNull R> flatMapIterable(Function> mapper, int prefetch) { return onAssembly(new FluxFlattenIterable<>(this, mapper, prefetch, Queues.get(prefetch))); } @@ -4137,8 +4138,8 @@ public final Flux flatMapIterable(Function Flux flatMapSequential(Function> mapper) { + public final Flux<@NonNull R> flatMapSequential(Function> mapper) { return flatMapSequential(mapper, Queues.SMALL_BUFFER_SIZE); } @@ -4178,8 +4179,8 @@ public final Flux flatMapSequential(Function Flux flatMapSequential(Function> mapper, int maxConcurrency) { + public final Flux<@NonNull R> flatMapSequential(Function> mapper, int maxConcurrency) { return flatMapSequential(mapper, maxConcurrency, Queues.XS_BUFFER_SIZE); } @@ -4222,8 +4223,8 @@ public final Flux flatMapSequential(Function Flux flatMapSequential(Function> mapper, int maxConcurrency, int prefetch) { + public final Flux<@NonNull R> flatMapSequential(Function> mapper, int maxConcurrency, int prefetch) { return flatMapSequential(mapper, false, maxConcurrency, prefetch); } @@ -4267,8 +4268,8 @@ public final Flux flatMapSequential(Function Flux flatMapSequentialDelayError(Function> mapper, int maxConcurrency, int prefetch) { + public final Flux<@NonNull R> flatMapSequentialDelayError(Function> mapper, int maxConcurrency, int prefetch) { return flatMapSequential(mapper, true, maxConcurrency, prefetch); } @@ -4300,7 +4301,7 @@ public int getPrefetch() { * * @return a {@link Flux} of {@link GroupedFlux} grouped sequences */ - public final Flux> groupBy(Function keyMapper) { + public final Flux<@NonNull GroupedFlux<@NonNull K, @NonNull T>> groupBy(Function keyMapper) { return groupBy(keyMapper, identityFunction()); } @@ -4325,7 +4326,7 @@ public final Flux> groupBy(Function Flux> groupBy(Function keyMapper, int prefetch) { + public final Flux<@NonNull GroupedFlux<@NonNull K, @NonNull T>> groupBy(Function keyMapper, int prefetch) { return groupBy(keyMapper, identityFunction(), prefetch); } @@ -4353,8 +4354,8 @@ public final Flux> groupBy(Function Flux> groupBy(Function keyMapper, - Function valueMapper) { + public final Flux<@NonNull GroupedFlux<@NonNull K, @NonNull V>> groupBy(Function keyMapper, + Function valueMapper) { return groupBy(keyMapper, valueMapper, Queues.SMALL_BUFFER_SIZE); } @@ -4384,8 +4385,8 @@ public final Flux> groupBy(Function Flux> groupBy(Function keyMapper, - Function valueMapper, int prefetch) { + public final Flux<@NonNull GroupedFlux<@NonNull K, @NonNull V>> groupBy(Function keyMapper, + Function valueMapper, int prefetch) { return onAssembly(new FluxGroupBy<>(this, keyMapper, valueMapper, Queues.unbounded(prefetch), Queues.unbounded(prefetch), prefetch)); @@ -4422,11 +4423,11 @@ public final Flux> groupBy(Function Flux groupJoin( - Publisher other, - Function> leftEnd, - Function> rightEnd, - BiFunction, ? extends R> resultSelector + public final Flux<@NonNull R> groupJoin( + Publisher other, + Function> leftEnd, + Function> rightEnd, + BiFunction, ? extends @NonNull R> resultSelector ) { return onAssembly(new FluxGroupJoin( this, other, leftEnd, rightEnd, resultSelector, @@ -4445,7 +4446,7 @@ public final Flux groupJoin( * * @return a transformed {@link Flux} */ - public final Flux handle(BiConsumer> handler) { + public final Flux handle(BiConsumer> handler) { if (this instanceof Fuseable) { return onAssembly(new FluxHandleFuseable<>(this, handler)); } @@ -4539,11 +4540,11 @@ public final Mono ignoreElements() { * @return a joining {@link Flux} * @see #groupJoin(Publisher, Function, Function, BiFunction) */ - public final Flux join( - Publisher other, - Function> leftEnd, - Function> rightEnd, - BiFunction resultSelector + public final Flux<@NonNull R> join( + Publisher other, + Function> leftEnd, + Function> rightEnd, + BiFunction resultSelector ) { return onAssembly(new FluxJoin( this, other, leftEnd, rightEnd, resultSelector, Queues @@ -4560,7 +4561,7 @@ public final Flux join( * * @return a {@link Mono} with the last value in this {@link Flux} */ - public final Mono last() { + public final Mono<@NonNull T> last() { if (this instanceof Callable) { @SuppressWarnings("unchecked") Callable thiz = (Callable)this; @@ -4579,7 +4580,7 @@ public final Mono last() { * @param defaultValue a single fallback item if this {@link Flux} is empty * @return a {@link Mono} with the last value in this {@link Flux} */ - public final Mono last(T defaultValue) { + public final Mono<@NonNull T> last(T defaultValue) { if (this instanceof Callable) { @SuppressWarnings("unchecked") Callable thiz = (Callable)this; @@ -4610,7 +4611,7 @@ public final Mono last(T defaultValue) { *

* Typically used for scenarios where consumer(s) request a large amount of data * (eg. {@code Long.MAX_VALUE}) but the data source behaves better or can be optimized - * with smaller requests (eg. database paging, etc...). All data is still processed. + * with smaller requests (eg. database paging, etc ...). All data is still processed. *

* Equivalent to {@code flux.publishOn(Schedulers.immediate(), prefetchRate).subscribe() } * @@ -4619,7 +4620,7 @@ public final Mono last(T defaultValue) { * @return a {@link Flux} limiting downstream's backpressure * @see #publishOn(Scheduler, int) */ - public final Flux limitRate(int prefetchRate) { + public final Flux<@NonNull T> limitRate(int prefetchRate) { return onAssembly(this.publishOn(Schedulers.immediate(), prefetchRate)); } @@ -4635,7 +4636,7 @@ public final Flux limitRate(int prefetchRate) { * * @return a new {@link Flux} that logs signals */ - public final Flux log() { + public final Flux<@NonNull T> log() { return log(null, Level.INFO); } @@ -4652,7 +4653,7 @@ public final Flux log() { * * @return a new {@link Flux} that logs signals */ - public final Flux log(String category) { + public final Flux<@NonNull T> log(String category) { return log(category, Level.INFO); } @@ -4677,7 +4678,7 @@ public final Flux log(String category) { * * @return a new {@link Flux} that logs signals */ - public final Flux log(@Nullable String category, Level level, SignalType... options) { + public final Flux<@NonNull T> log(@Nullable String category, Level level, SignalType @NonNull ... options) { return log(category, level, false, options); } @@ -4704,10 +4705,10 @@ public final Flux log(@Nullable String category, Level level, SignalType... o * * @return a new {@link Flux} that logs signals */ - public final Flux log(@Nullable String category, + public final Flux<@NonNull T> log(@Nullable String category, Level level, boolean showOperatorLine, - SignalType... options) { + SignalType @NonNull ... options) { SignalLogger log = new SignalLogger<>(this, category, level, showOperatorLine, options); @@ -4728,7 +4729,7 @@ public final Flux log(@Nullable String category, * * @return a transformed {@link Flux} */ - public final Flux map(Function mapper) { + public final Flux<@NonNull V> map(Function mapper) { if (this instanceof Fuseable) { return onAssembly(new FluxMapFuseable<>(this, mapper)); } @@ -4747,7 +4748,7 @@ public final Flux map(Function mapper) { * @return a {@link Flux} of materialized {@link Signal} * @see #dematerialize() */ - public final Flux> materialize() { + public final Flux<@NonNull Signal<@NonNull T>> materialize() { return onAssembly(new FluxMaterialize<>(this)); } @@ -4767,7 +4768,7 @@ public final Flux> materialize() { * * @return a new {@link Flux} */ - public final Flux mergeWith(Publisher other) { + public final Flux<@NonNull T> mergeWith(Publisher other) { if (this instanceof FluxMerge) { FluxMerge fluxMerge = (FluxMerge) this; return fluxMerge.mergeAdditionalSource(other, Queues::get); @@ -4782,7 +4783,7 @@ public final Flux mergeWith(Publisher other) { * @param name a name for the sequence * @return the same sequence, but bearing a name */ - public final Flux name(String name) { + public final Flux<@NonNull T> name(String name) { return FluxName.createOrAppend(this, name); } @@ -4794,7 +4795,7 @@ public final Flux name(String name) { * * @return a new {@link Mono} emitting the first value in this {@link Flux} */ - public final Mono next() { + public final Mono<@NonNull T> next() { if(this instanceof Callable){ @SuppressWarnings("unchecked") Callable m = (Callable)this; @@ -4815,7 +4816,7 @@ public final Mono next() { * * @return a new {@link Flux} filtered on items of the requested type */ - public final Flux ofType(final Class clazz) { + public final Flux<@NonNull U> ofType(final Class clazz) { Objects.requireNonNull(clazz, "clazz"); return filter(o -> clazz.isAssignableFrom(o.getClass())).cast(clazz); } @@ -4831,7 +4832,7 @@ public final Flux ofType(final Class clazz) { * @return a backpressured {@link Flux} that buffers with unbounded capacity * */ - public final Flux onBackpressureBuffer() { + public final Flux<@NonNull T> onBackpressureBuffer() { return onAssembly(new FluxOnBackpressureBuffer<>(this, Queues .SMALL_BUFFER_SIZE, true, null)); } @@ -4849,7 +4850,7 @@ public final Flux onBackpressureBuffer() { * @return a backpressured {@link Flux} that buffers with bounded capacity * */ - public final Flux onBackpressureBuffer(int maxSize) { + public final Flux<@NonNull T> onBackpressureBuffer(int maxSize) { return onAssembly(new FluxOnBackpressureBuffer<>(this, maxSize, false, null)); } @@ -4868,7 +4869,7 @@ public final Flux onBackpressureBuffer(int maxSize) { * @return a backpressured {@link Flux} that buffers with a bounded capacity * */ - public final Flux onBackpressureBuffer(int maxSize, Consumer onOverflow) { + public final Flux<@NonNull T> onBackpressureBuffer(int maxSize, Consumer onOverflow) { Objects.requireNonNull(onOverflow, "onOverflow"); return onAssembly(new FluxOnBackpressureBuffer<>(this, maxSize, false, onOverflow)); } @@ -4890,7 +4891,7 @@ public final Flux onBackpressureBuffer(int maxSize, Consumer onOve * @return a backpressured {@link Flux} that buffers up to a capacity then applies an * overflow strategy */ - public final Flux onBackpressureBuffer(int maxSize, BufferOverflowStrategy bufferOverflowStrategy) { + public final Flux<@NonNull T> onBackpressureBuffer(int maxSize, BufferOverflowStrategy bufferOverflowStrategy) { Objects.requireNonNull(bufferOverflowStrategy, "bufferOverflowStrategy"); return onAssembly(new FluxOnBackpressureBufferStrategy<>(this, maxSize, null, bufferOverflowStrategy)); @@ -4921,7 +4922,7 @@ public final Flux onBackpressureBuffer(int maxSize, BufferOverflowStrategy bu * @return a backpressured {@link Flux} that buffers up to a capacity then applies an * overflow strategy */ - public final Flux onBackpressureBuffer(int maxSize, Consumer onBufferOverflow, + public final Flux<@NonNull T> onBackpressureBuffer(int maxSize, Consumer onBufferOverflow, BufferOverflowStrategy bufferOverflowStrategy) { Objects.requireNonNull(onBufferOverflow, "onBufferOverflow"); Objects.requireNonNull(bufferOverflowStrategy, "bufferOverflowStrategy"); @@ -4949,7 +4950,7 @@ public final Flux onBackpressureBuffer(int maxSize, Consumer onBuf * @return a backpressured {@link Flux} that buffers with a TTL and up to a capacity then applies an * overflow strategy */ - public final Flux onBackpressureBuffer(Duration ttl, int maxSize, Consumer onBufferEviction) { + public final Flux<@NonNull T> onBackpressureBuffer(Duration ttl, int maxSize, Consumer onBufferEviction) { return onBackpressureBuffer(ttl, maxSize, onBufferEviction, Schedulers.parallel()); } @@ -4973,7 +4974,7 @@ public final Flux onBackpressureBuffer(Duration ttl, int maxSize, Consumer onBackpressureBuffer(Duration ttl, int maxSize, Consumer onBufferEviction, Scheduler scheduler) { + public final Flux<@NonNull T> onBackpressureBuffer(Duration ttl, int maxSize, Consumer onBufferEviction, Scheduler scheduler) { Objects.requireNonNull(ttl, "ttl"); Objects.requireNonNull(onBufferEviction, "onBufferEviction"); return onAssembly(new FluxOnBackpressureBufferTimeout<>(this, ttl, scheduler, maxSize, onBufferEviction)); @@ -4988,7 +4989,7 @@ public final Flux onBackpressureBuffer(Duration ttl, int maxSize, Consumer onBackpressureDrop() { + public final Flux<@NonNull T> onBackpressureDrop() { return onAssembly(new FluxOnBackpressureDrop<>(this)); } @@ -5003,7 +5004,7 @@ public final Flux onBackpressureDrop() { * @param onDropped the Consumer called when an value gets dropped due to lack of downstream requests * @return a backpressured {@link Flux} that drops overflowing elements */ - public final Flux onBackpressureDrop(Consumer onDropped) { + public final Flux<@NonNull T> onBackpressureDrop(Consumer onDropped) { return onAssembly(new FluxOnBackpressureDrop<>(this, onDropped)); } @@ -5017,7 +5018,7 @@ public final Flux onBackpressureDrop(Consumer onDropped) { * * @return a backpressured {@link Flux} that errors on overflowing elements */ - public final Flux onBackpressureError() { + public final Flux<@NonNull T> onBackpressureError() { return onBackpressureDrop(t -> { throw Exceptions.failWithOverflow();}); } @@ -5030,7 +5031,7 @@ public final Flux onBackpressureError() { * * @return a backpressured {@link Flux} that will only keep a reference to the last observed item */ - public final Flux onBackpressureLatest() { + public final Flux<@NonNull T> onBackpressureLatest() { return onAssembly(new FluxOnBackpressureLatest<>(this)); } @@ -5046,7 +5047,7 @@ public final Flux onBackpressureLatest() { * * @return a {@link Flux} that transforms source errors to other errors */ - public final Flux onErrorMap(Function mapper) { + public final Flux<@NonNull T> onErrorMap(Function mapper) { return onErrorResume(e -> Mono.error(mapper.apply(e))); } @@ -5062,8 +5063,8 @@ public final Flux onErrorMap(Function * * @return a {@link Flux} that transforms some source errors to other errors */ - public final Flux onErrorMap(Class type, - Function mapper) { + public final Flux<@NonNull T> onErrorMap(Class type, + Function mapper) { @SuppressWarnings("unchecked") Function handler = (Function)mapper; return onErrorMap(type::isInstance, handler); @@ -5081,8 +5082,8 @@ public final Flux onErrorMap(Class type, * * @return a {@link Flux} that transforms some source errors to other errors */ - public final Flux onErrorMap(Predicate predicate, - Function mapper) { + public final Flux<@NonNull T> onErrorMap(Predicate predicate, + Function mapper) { return onErrorResume(predicate, e -> Mono.error(mapper.apply(e))); } @@ -5097,7 +5098,7 @@ public final Flux onErrorMap(Predicate predicate, * * @return a {@link Flux} falling back upon source onError */ - public final Flux onErrorResume(Function> fallback) { + public final Flux<@NonNull T> onErrorResume(Function> fallback) { return onAssembly(new FluxOnErrorResume<>(this, fallback)); } @@ -5114,8 +5115,8 @@ public final Flux onErrorResume(Function Flux onErrorResume(Class type, - Function> fallback) { + public final Flux<@NonNull T> onErrorResume(Class type, + Function> fallback) { Objects.requireNonNull(type, "type"); @SuppressWarnings("unchecked") Function> handler = (Function Flux onErrorResume(Class type, * * @return a {@link Flux} falling back upon source onError */ - public final Flux onErrorResume(Predicate predicate, - Function> fallback) { + public final Flux<@NonNull T> onErrorResume(Predicate predicate, + Function> fallback) { Objects.requireNonNull(predicate, "predicate"); return onErrorResume(e -> predicate.test(e) ? fallback.apply(e) : error(e)); } @@ -5150,7 +5151,7 @@ public final Flux onErrorResume(Predicate predicate, * * @return a new falling back {@link Flux} */ - public final Flux onErrorReturn(T fallbackValue) { + public final Flux<@NonNull T> onErrorReturn(T fallbackValue) { return onErrorResume(t -> just(fallbackValue)); } @@ -5165,7 +5166,7 @@ public final Flux onErrorReturn(T fallbackValue) { * * @return a new falling back {@link Flux} */ - public final Flux onErrorReturn(Class type, + public final Flux<@NonNull T> onErrorReturn(Class type, T fallbackValue) { return onErrorResume(type, t -> just(fallbackValue)); } @@ -5180,7 +5181,7 @@ public final Flux onErrorReturn(Class type, * * @return a new falling back {@link Flux} */ - public final Flux onErrorReturn(Predicate predicate, T fallbackValue) { + public final Flux<@NonNull T> onErrorReturn(Predicate predicate, T fallbackValue) { return onErrorResume(predicate, t -> just(fallbackValue)); } @@ -5192,7 +5193,7 @@ public final Flux onErrorReturn(Predicate predicate, T fal * * @return a detachable {@link Flux} */ - public final Flux onTerminateDetach() { + public final Flux<@NonNull T> onTerminateDetach() { return new FluxDetach<>(this); } @@ -5232,7 +5233,7 @@ public final Flux or(Publisher other) { * * @return a new {@link ParallelFlux} instance */ - public final ParallelFlux parallel() { + public final ParallelFlux<@NonNull T> parallel() { return parallel(Runtime.getRuntime() .availableProcessors()); } @@ -5250,7 +5251,7 @@ public final ParallelFlux parallel() { * * @return a new {@link ParallelFlux} instance */ - public final ParallelFlux parallel(int parallelism) { + public final ParallelFlux<@NonNull T> parallel(int parallelism) { return parallel(parallelism, Queues.SMALL_BUFFER_SIZE); } @@ -5269,7 +5270,7 @@ public final ParallelFlux parallel(int parallelism) { * * @return a new {@link ParallelFlux} instance */ - public final ParallelFlux parallel(int parallelism, int prefetch) { + public final ParallelFlux<@NonNull T> parallel(int parallelism, int prefetch) { return ParallelFlux.from(this, parallelism, prefetch, @@ -5290,7 +5291,7 @@ public final ParallelFlux parallel(int parallelism, int prefetch) { * * @return a new {@link ConnectableFlux} */ - public final ConnectableFlux publish() { + public final ConnectableFlux<@NonNull T> publish() { return publish(Queues.SMALL_BUFFER_SIZE); } @@ -5309,7 +5310,7 @@ public final ConnectableFlux publish() { * * @return a new {@link ConnectableFlux} */ - public final ConnectableFlux publish(int prefetch) { + public final ConnectableFlux<@NonNull T> publish(int prefetch) { return onAssembly(new FluxPublish<>(this, prefetch, Queues .get(prefetch))); } @@ -5324,8 +5325,8 @@ public final ConnectableFlux publish(int prefetch) { * * @return a new {@link Flux} */ - public final Flux publish(Function, ? extends Publisher> transform) { + public final Flux<@NonNull R> publish(Function, ? extends @NonNull Publisher> transform) { return publish(transform, Queues.SMALL_BUFFER_SIZE); } @@ -5340,8 +5341,8 @@ public final Flux publish(Function, ? extends Publisher Flux publish(Function, ? extends Publisher> transform, int prefetch) { + public final Flux<@NonNull R> publish(Function, ? extends @NonNull Publisher> transform, int prefetch) { return onAssembly(new FluxPublishMulticast<>(this, transform, prefetch, Queues .get(prefetch))); } @@ -5356,7 +5357,7 @@ public final Flux publish(Function, ? extends Publisher publishNext() { + public final Mono<@NonNull T> publishNext() { return Mono.onAssembly(new MonoProcessor<>(this)); } @@ -5378,7 +5379,7 @@ public final Mono publishNext() { * * @return a {@link Flux} producing asynchronously on a given {@link Scheduler} */ - public final Flux publishOn(Scheduler scheduler) { + public final Flux<@NonNull T> publishOn(Scheduler scheduler) { return publishOn(scheduler, Queues.SMALL_BUFFER_SIZE); } @@ -5401,7 +5402,7 @@ public final Flux publishOn(Scheduler scheduler) { * * @return a {@link Flux} producing asynchronously */ - public final Flux publishOn(Scheduler scheduler, int prefetch) { + public final Flux<@NonNull T> publishOn(Scheduler scheduler, int prefetch) { return publishOn(scheduler, true, prefetch); } @@ -5425,7 +5426,7 @@ public final Flux publishOn(Scheduler scheduler, int prefetch) { * * @return a {@link Flux} producing asynchronously */ - public final Flux publishOn(Scheduler scheduler, boolean delayError, int prefetch) { + public final Flux<@NonNull T> publishOn(Scheduler scheduler, boolean delayError, int prefetch) { if (this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { @SuppressWarnings("unchecked") @@ -5459,7 +5460,7 @@ public final Flux publishOn(Scheduler scheduler, boolean delayError, int pref * * @return a reduced {@link Flux} */ - public final Mono reduce(BiFunction aggregator) { + public final Mono<@NonNull T> reduce(BiFunction<@NonNull T, @NonNull T, @NonNull T> aggregator) { if (this instanceof Callable){ @SuppressWarnings("unchecked") Callable thiz = (Callable)this; @@ -5485,7 +5486,7 @@ public final Mono reduce(BiFunction aggregator) { * @return a reduced {@link Flux} * */ - public final Mono reduce(A initial, BiFunction accumulator) { + public final Mono<@NonNull A> reduce(A initial, BiFunction<@NonNull A, ? super @NonNull T, @NonNull A> accumulator) { return reduceWith(() -> initial, accumulator); } @@ -5506,7 +5507,7 @@ public final Mono reduce(A initial, BiFunction accumulat * @return a reduced {@link Flux} * */ - public final Mono reduceWith(Supplier initial, BiFunction accumulator) { + public final Mono<@NonNull A> reduceWith(Supplier<@NonNull A> initial, BiFunction<@NonNull A, ? super @NonNull T, @NonNull A> accumulator) { return Mono.onAssembly(new MonoReduceSeed<>(this, initial, accumulator)); } @@ -5519,7 +5520,7 @@ public final Mono reduceWith(Supplier initial, BiFunction repeat() { + public final Flux<@NonNull T> repeat() { return repeat(ALWAYS_BOOLEAN_SUPPLIER); } @@ -5533,7 +5534,7 @@ public final Flux repeat() { * * @return a {@link Flux} that repeats on onComplete while the predicate matches */ - public final Flux repeat(BooleanSupplier predicate) { + public final Flux<@NonNull T> repeat(BooleanSupplier predicate) { return onAssembly(new FluxRepeatPredicate<>(this, predicate)); } @@ -5547,7 +5548,7 @@ public final Flux repeat(BooleanSupplier predicate) { * * @return a {@link Flux} that repeats on onComplete, up to the specified number of repetitions */ - public final Flux repeat(long numRepeat) { + public final Flux<@NonNull T> repeat(long numRepeat) { if(numRepeat == 0L){ return empty(); } @@ -5567,7 +5568,7 @@ public final Flux repeat(long numRepeat) { * @return a {@link Flux} that repeats on onComplete while the predicate matches, * up to the specified number of repetitions */ - public final Flux repeat(long numRepeat, BooleanSupplier predicate) { + public final Flux<@NonNull T> repeat(long numRepeat, BooleanSupplier predicate) { return defer( () -> repeat(countingBooleanSupplier(predicate, numRepeat))); } @@ -5587,7 +5588,7 @@ public final Flux repeat(long numRepeat, BooleanSupplier predicate) { * @return a {@link Flux} that repeats on onComplete when the companion {@link Publisher} produces an * onNext signal */ - public final Flux repeatWhen(Function, ? extends Publisher> repeatFactory) { + public final Flux<@NonNull T> repeatWhen(Function<@NonNull Flux<@NonNull Long>, ? extends @NonNull Publisher<@NonNull ?>> repeatFactory) { return onAssembly(new FluxRepeatWhen<>(this, repeatFactory)); } @@ -5601,7 +5602,7 @@ public final Flux repeatWhen(Function, ? extends Publisher> rep * * @return a replaying {@link ConnectableFlux} */ - public final ConnectableFlux replay() { + public final ConnectableFlux<@NonNull T> replay() { return replay(Integer.MAX_VALUE); } @@ -5623,7 +5624,7 @@ public final ConnectableFlux replay() { * @return a replaying {@link ConnectableFlux} * */ - public final ConnectableFlux replay(int history) { + public final ConnectableFlux<@NonNull T> replay(int history) { return onAssembly(new FluxReplay<>(this, history, 0L, null)); } @@ -5643,7 +5644,7 @@ public final ConnectableFlux replay(int history) { * * @return a replaying {@link ConnectableFlux} */ - public final ConnectableFlux replay(Duration ttl) { + public final ConnectableFlux<@NonNull T> replay(Duration ttl) { return replay(Integer.MAX_VALUE, ttl); } @@ -5664,7 +5665,7 @@ public final ConnectableFlux replay(Duration ttl) { * * @return a replaying {@link ConnectableFlux} */ - public final ConnectableFlux replay(int history, Duration ttl) { + public final ConnectableFlux<@NonNull T> replay(int history, Duration ttl) { return replay(history, ttl, Schedulers.parallel()); } @@ -5684,7 +5685,7 @@ public final ConnectableFlux replay(int history, Duration ttl) { * * @return a replaying {@link ConnectableFlux} */ - public final ConnectableFlux replay(Duration ttl, Scheduler timer) { + public final ConnectableFlux<@NonNull T> replay(Duration ttl, Scheduler timer) { return replay(Integer.MAX_VALUE, ttl, timer); } @@ -5705,7 +5706,7 @@ public final ConnectableFlux replay(Duration ttl, Scheduler timer) { * * @return a replaying {@link ConnectableFlux} */ - public final ConnectableFlux replay(int history, Duration ttl, Scheduler timer) { + public final ConnectableFlux<@NonNull T> replay(int history, Duration ttl, Scheduler timer) { Objects.requireNonNull(timer, "timer"); return onAssembly(new FluxReplay<>(this, history, ttl.toMillis(), timer)); } @@ -5717,7 +5718,7 @@ public final ConnectableFlux replay(int history, Duration ttl, Scheduler time * * @return a {@link Flux} that retries on onError */ - public final Flux retry() { + public final Flux<@NonNull T> retry() { return retry(Long.MAX_VALUE); } @@ -5734,7 +5735,7 @@ public final Flux retry() { * @return a {@link Flux} that retries on onError up to the specified number of retry attempts. * */ - public final Flux retry(long numRetries) { + public final Flux<@NonNull T> retry(long numRetries) { return onAssembly(new FluxRetry<>(this, numRetries)); } @@ -5749,7 +5750,7 @@ public final Flux retry(long numRetries) { * * @return a {@link Flux} that retries on onError if the predicates matches. */ - public final Flux retry(Predicate retryMatcher) { + public final Flux<@NonNull T> retry(Predicate retryMatcher) { return onAssembly(new FluxRetryPredicate<>(this, retryMatcher)); } @@ -5766,7 +5767,7 @@ public final Flux retry(Predicate retryMatcher) { * @return a {@link Flux} that retries on onError up to the specified number of retry * attempts, only if the predicate matches. */ - public final Flux retry(long numRetries, Predicate retryMatcher) { + public final Flux<@NonNull T> retry(long numRetries, Predicate retryMatcher) { return defer(() -> retry(countingPredicate(retryMatcher, numRetries))); } @@ -5786,7 +5787,7 @@ public final Flux retry(long numRetries, Predicate retryMa * @return a {@link Flux} that retries on onError when the companion {@link Publisher} produces an * onNext signal */ - public final Flux retryWhen(Function, ? extends Publisher> whenFactory) { + public final Flux<@NonNull T> retryWhen(Function<@NonNull Flux<@NonNull Throwable>, ? extends @NonNull Publisher<@NonNull ?>> whenFactory) { return onAssembly(new FluxRetryWhen<>(this, whenFactory)); } @@ -5804,7 +5805,7 @@ public final Flux retryWhen(Function, ? extends Publisher> * * @return a {@link Flux} sampled to the last item seen over each periodic window */ - public final Flux sample(Duration timespan) { + public final Flux<@NonNull T> sample(Duration timespan) { return sample(interval(timespan)); } @@ -5830,7 +5831,7 @@ public final Flux sample(Duration timespan) { * * @return a {@link Flux} sampled to the last item observed each time the sampler {@link Publisher} signals */ - public final Flux sample(Publisher sampler) { + public final Flux<@NonNull T> sample(Publisher<@NonNull U> sampler) { return onAssembly(new FluxSample<>(this, sampler)); } @@ -5845,7 +5846,7 @@ public final Flux sample(Publisher sampler) { * * @return a {@link Flux} sampled to the first item of each duration-based window */ - public final Flux sampleFirst(Duration timespan) { + public final Flux<@NonNull T> sampleFirst(Duration timespan) { return sampleFirst(t -> Mono.delay(timespan)); } @@ -5861,7 +5862,7 @@ public final Flux sampleFirst(Duration timespan) { * * @return a {@link Flux} sampled to the first item observed in each window closed by the sampler signals */ - public final Flux sampleFirst(Function> samplerFactory) { + public final Flux<@NonNull T> sampleFirst(Function> samplerFactory) { return onAssembly(new FluxSampleFirst<>(this, samplerFactory)); } @@ -5883,7 +5884,7 @@ public final Flux sampleFirst(Function> * @return a {@link Flux} sampled to items not followed by any other item within a window * defined by a companion {@link Publisher} */ - public final Flux sampleTimeout(Function> throttlerFactory) { + public final Flux<@NonNull T> sampleTimeout(Function> throttlerFactory) { return sampleTimeout(throttlerFactory, Queues.XS_BUFFER_SIZE); } @@ -5908,7 +5909,7 @@ public final Flux sampleTimeout(Function Flux sampleTimeout(Function> + public final Flux<@NonNull T> sampleTimeout(Function> throttlerFactory, int maxConcurrency) { return onAssembly(new FluxSampleTimeout<>(this, throttlerFactory, Queues.get(maxConcurrency))); @@ -5937,7 +5938,7 @@ public final Flux sampleTimeout(Function scan(BiFunction accumulator) { + public final Flux<@NonNull T> scan(BiFunction<@NonNull T, @NonNull T, @NonNull T> accumulator) { return onAssembly(new FluxScan<>(this, accumulator)); } @@ -5964,7 +5965,7 @@ public final Flux scan(BiFunction accumulator) { * @return an accumulating {@link Flux} starting with initial state * */ - public final Flux scan(A initial, BiFunction accumulator) { + public final Flux<@NonNull A> scan(A initial, BiFunction<@NonNull A, ? super @NonNull T, @NonNull A> accumulator) { Objects.requireNonNull(initial, "seed"); return scanWith(() -> initial, accumulator); } @@ -5994,7 +5995,7 @@ public final Flux scan(A initial, BiFunction accumulator * @return an accumulating {@link Flux} starting with initial state * */ - public final Flux scanWith(Supplier initial, BiFunction + public final Flux<@NonNull A> scanWith(Supplier<@NonNull A> initial, BiFunction<@NonNull A, ? super @NonNull T, @NonNull A> accumulator) { return onAssembly(new FluxScanSeed<>(this, initial, accumulator)); } @@ -6010,7 +6011,7 @@ public final Flux scanWith(Supplier initial, BiFunction share() { + public final Flux<@NonNull T> share() { return onAssembly(new FluxRefCount<>( new FluxPublish<>(this, Queues.SMALL_BUFFER_SIZE, Queues.small()), 1) ); @@ -6026,7 +6027,7 @@ public final Flux share() { * * @return a {@link Mono} with the single item or an error signal */ - public final Mono single() { + public final Mono<@NonNull T> single() { if (this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { @SuppressWarnings("unchecked") @@ -6063,7 +6064,7 @@ public final Mono single() { * @return a {@link Mono} with the expected single item, the supplied default value or * and error signal */ - public final Mono single(T defaultValue) { + public final Mono<@NonNull T> single(T defaultValue) { if (this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { @SuppressWarnings("unchecked") @@ -6097,7 +6098,7 @@ public final Mono single(T defaultValue) { * * @return a {@link Mono} with the expected single item, no item or an error */ - public final Mono singleOrEmpty() { + public final Mono<@NonNull T> singleOrEmpty() { if (this instanceof Callable) { @SuppressWarnings("unchecked") Callable thiz = (Callable)this; @@ -6118,7 +6119,7 @@ public final Mono singleOrEmpty() { * @return a dropping {@link Flux} with the specified number of elements skipped at * the beginning */ - public final Flux skip(long skipped) { + public final Flux<@NonNull T> skip(long skipped) { if (skipped == 0L) { return this; } @@ -6137,7 +6138,7 @@ public final Flux skip(long skipped) { * * @return a {@link Flux} dropping at the beginning until the end of the given duration */ - public final Flux skip(Duration timespan) { + public final Flux<@NonNull T> skip(Duration timespan) { return skip(timespan, Schedulers.parallel()); } @@ -6153,7 +6154,7 @@ public final Flux skip(Duration timespan) { * * @return a {@link Flux} dropping at the beginning for the given duration */ - public final Flux skip(Duration timespan, Scheduler timer) { + public final Flux<@NonNull T> skip(Duration timespan, Scheduler timer) { if(!timespan.isZero()) { return skipUntilOther(Mono.delay(timespan, timer)); } @@ -6174,7 +6175,7 @@ public final Flux skip(Duration timespan, Scheduler timer) { * sequence * */ - public final Flux skipLast(int n) { + public final Flux<@NonNull T> skipLast(int n) { if (n == 0) { return this; } @@ -6192,7 +6193,7 @@ public final Flux skipLast(int n) { * * @return a {@link Flux} dropping until the {@link Predicate} matches */ - public final Flux skipUntil(Predicate untilPredicate) { + public final Flux<@NonNull T> skipUntil(Predicate untilPredicate) { return onAssembly(new FluxSkipUntil<>(this, untilPredicate)); } @@ -6208,7 +6209,7 @@ public final Flux skipUntil(Predicate untilPredicate) { * @return a {@link Flux} dropping until the other {@link Publisher} emits * */ - public final Flux skipUntilOther(Publisher other) { + public final Flux<@NonNull T> skipUntilOther(Publisher<@NonNull ?> other) { return onAssembly(new FluxSkipUntilOther<>(this, other)); } @@ -6222,7 +6223,7 @@ public final Flux skipUntilOther(Publisher other) { * * @return a {@link Flux} dropping while the {@link Predicate} matches */ - public final Flux skipWhile(Predicate skipPredicate) { + public final Flux<@NonNull T> skipWhile(Predicate skipPredicate) { return onAssembly(new FluxSkipWhile<>(this, skipPredicate)); } @@ -6239,7 +6240,7 @@ public final Flux skipWhile(Predicate skipPredicate) { * {@link Comparable} with respect to all other items emitted by the {@link Flux} * @return a sorted {@link Flux} */ - public final Flux sort(){ + public final Flux<@NonNull T> sort(){ return collectSortedList().flatMapIterable(identityFunction()); } @@ -6255,7 +6256,7 @@ public final Flux sort(){ * to indicate their sort order * @return a sorted {@link Flux} */ - public final Flux sort(Comparator sortFunction) { + public final Flux<@NonNull T> sort(Comparator sortFunction) { return collectSortedList(sortFunction).flatMapIterable(identityFunction()); } @@ -6269,7 +6270,7 @@ public final Flux sort(Comparator sortFunction) { * * @return a new {@link Flux} prefixed with elements from an {@link Iterable} */ - public final Flux startWith(Iterable iterable) { + public final Flux<@NonNull T> startWith(Iterable iterable) { return startWith(fromIterable(iterable)); } @@ -6284,7 +6285,7 @@ public final Flux startWith(Iterable iterable) { * @return a new {@link Flux} prefixed with the given elements */ @SafeVarargs - public final Flux startWith(T... values) { + public final Flux<@NonNull T> startWith(T @NonNull ... values) { return startWith(just(values)); } @@ -6298,7 +6299,7 @@ public final Flux startWith(T... values) { * * @return a new {@link Flux} prefixed with the given {@link Publisher} sequence */ - public final Flux startWith(Publisher publisher) { + public final Flux<@NonNull T> startWith(Publisher publisher) { if (this instanceof FluxConcatArray) { FluxConcatArray fluxConcatArray = (FluxConcatArray) this; return fluxConcatArray.concatAdditionalSourceFirst(publisher); @@ -6342,7 +6343,7 @@ public final Disposable subscribe() { * * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ - public final Disposable subscribe(Consumer consumer) { + public final Disposable subscribe(Consumer consumer) { Objects.requireNonNull(consumer, "consumer"); return subscribe(consumer, null, null); } @@ -6369,7 +6370,7 @@ public final Disposable subscribe(Consumer consumer) { * * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ - public final Disposable subscribe(@Nullable Consumer consumer, Consumer errorConsumer) { + public final Disposable subscribe(@Nullable Consumer consumer, Consumer errorConsumer) { Objects.requireNonNull(errorConsumer, "errorConsumer"); return subscribe(consumer, errorConsumer, null); } @@ -6398,8 +6399,8 @@ public final Disposable subscribe(@Nullable Consumer consumer, Consum * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ public final Disposable subscribe( - @Nullable Consumer consumer, - @Nullable Consumer errorConsumer, + @Nullable Consumer consumer, + @Nullable Consumer errorConsumer, @Nullable Runnable completeConsumer) { return subscribe(consumer, errorConsumer, completeConsumer, null); } @@ -6433,17 +6434,17 @@ public final Disposable subscribe( * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ public final Disposable subscribe( - @Nullable Consumer consumer, - @Nullable Consumer errorConsumer, + @Nullable Consumer consumer, + @Nullable Consumer errorConsumer, @Nullable Runnable completeConsumer, - @Nullable Consumer subscriptionConsumer) { + @Nullable Consumer subscriptionConsumer) { return subscribeWith(new LambdaSubscriber<>(consumer, errorConsumer, completeConsumer, subscriptionConsumer)); } @Override - public final void subscribe(Subscriber actual) { + public final void subscribe(Subscriber actual) { onLastAssembly(this).subscribe(Operators.toCoreSubscriber(actual)); } @@ -6457,7 +6458,7 @@ public final void subscribe(Subscriber actual) { * @param actual the {@link Subscriber} interested into the published sequence * @see Flux#subscribe(Subscriber) */ - public abstract void subscribe(CoreSubscriber actual); + public abstract void subscribe(CoreSubscriber actual); /** * Enrich a potentially empty downstream {@link Context} by adding all values @@ -6479,7 +6480,7 @@ public final void subscribe(Subscriber actual) { * @return a contextualized {@link Flux} * @see Context */ - public final Flux subscriberContext(Context mergeContext) { + public final Flux<@NonNull T> subscriberContext(Context mergeContext) { return subscriberContext(c -> c.putAll(mergeContext)); } @@ -6503,7 +6504,7 @@ public final Flux subscriberContext(Context mergeContext) { * @return a contextualized {@link Flux} * @see Context */ - public final Flux subscriberContext(Function doOnContext) { + public final Flux<@NonNull T> subscriberContext(Function<@NonNull Context, @NonNull Context> doOnContext) { return new FluxContextStart<>(this, doOnContext); } @@ -6538,7 +6539,7 @@ public final Flux subscriberContext(Function doOnContext) { * @see #publishOn(Scheduler) * @see #subscribeOn(Scheduler, boolean) */ - public final Flux subscribeOn(Scheduler scheduler) { + public final Flux<@NonNull T> subscribeOn(Scheduler scheduler) { return subscribeOn(scheduler, true); } @@ -6577,7 +6578,7 @@ public final Flux subscribeOn(Scheduler scheduler) { * @see #publishOn(Scheduler) * @see #subscribeOn(Scheduler) */ - public final Flux subscribeOn(Scheduler scheduler, boolean requestOnSeparateThread) { + public final Flux<@NonNull T> subscribeOn(Scheduler scheduler, boolean requestOnSeparateThread) { if (this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { try { @@ -6610,7 +6611,7 @@ public final Flux subscribeOn(Scheduler scheduler, boolean requestOnSeparateT * * @return the passed {@link Subscriber} */ - public final > E subscribeWith(E subscriber) { + public final > E subscribeWith(E subscriber) { subscribe(subscriber); return subscriber; } @@ -6624,7 +6625,7 @@ public final > E subscribeWith(E subscriber) { * * @return a new {@link Flux} that falls back on a {@link Publisher} if source is empty */ - public final Flux switchIfEmpty(Publisher alternate) { + public final Flux<@NonNull T> switchIfEmpty(Publisher alternate) { return onAssembly(new FluxSwitchIfEmpty<>(this, alternate)); } @@ -6643,7 +6644,7 @@ public final Flux switchIfEmpty(Publisher alternate) { * for each source onNext * */ - public final Flux switchMap(Function> fn) { + public final Flux<@NonNull V> switchMap(Function> fn) { return switchMap(fn, Queues.XS_BUFFER_SIZE); } @@ -6663,7 +6664,7 @@ public final Flux switchMap(Function> f * @return a new {@link Flux} that emits values from an alternative {@link Publisher} * for each source onNext */ - public final Flux switchMap(Function> fn, int prefetch) { + public final Flux<@NonNull V> switchMap(Function> fn, int prefetch) { return onAssembly(new FluxSwitchMap<>(this, fn, Queues.unbounded(prefetch), prefetch)); } @@ -6677,7 +6678,7 @@ public final Flux switchMap(Function> f * @param value a tag value * @return the same sequence, but bearing tags */ - public final Flux tag(String key, String value) { + public final Flux<@NonNull T> tag(String key, String value) { return FluxName.createOrAppend(this, key, value); } @@ -6695,7 +6696,7 @@ public final Flux tag(String key, String value) { * * @return a {@link Flux} limited to size N */ - public final Flux take(long n) { + public final Flux<@NonNull T> take(long n) { if (this instanceof Fuseable) { return onAssembly(new FluxTakeFuseable<>(this, n)); } @@ -6716,7 +6717,7 @@ public final Flux take(long n) { * * @return a {@link Flux} limited to elements emitted within a specific duration */ - public final Flux take(Duration timespan) { + public final Flux<@NonNull T> take(Duration timespan) { return take(timespan, Schedulers.parallel()); } @@ -6736,7 +6737,7 @@ public final Flux take(Duration timespan) { * * @return a {@link Flux} limited to elements emitted within a specific duration */ - public final Flux take(Duration timespan, Scheduler timer) { + public final Flux<@NonNull T> take(Duration timespan, Scheduler timer) { if (!timespan.isZero()) { return takeUntilOther(Mono.delay(timespan, timer)); } @@ -6756,7 +6757,7 @@ public final Flux take(Duration timespan, Scheduler timer) { * @return a terminating {@link Flux} sub-sequence * */ - public final Flux takeLast(int n) { + public final Flux<@NonNull T> takeLast(int n) { if(n == 1){ return onAssembly(new FluxTakeLastOne<>(this)); } @@ -6776,7 +6777,7 @@ public final Flux takeLast(int n) { * @return a new {@link Flux} limited by the predicate * */ - public final Flux takeUntil(Predicate predicate) { + public final Flux<@NonNull T> takeUntil(Predicate predicate) { return onAssembly(new FluxTakeUntil<>(this, predicate)); } @@ -6791,7 +6792,7 @@ public final Flux takeUntil(Predicate predicate) { * @return a new {@link Flux} limited by a companion {@link Publisher} * */ - public final Flux takeUntilOther(Publisher other) { + public final Flux<@NonNull T> takeUntilOther(Publisher<@NonNull ?> other) { return onAssembly(new FluxTakeUntilOther<>(this, other)); } @@ -6808,7 +6809,7 @@ public final Flux takeUntilOther(Publisher other) { * * @return a new {@link Flux} taking values from the source while the predicate matches */ - public final Flux takeWhile(Predicate continuePredicate) { + public final Flux<@NonNull T> takeWhile(Predicate continuePredicate) { return onAssembly(new FluxTakeWhile<>(this, continuePredicate)); } @@ -6820,7 +6821,7 @@ public final Flux takeWhile(Predicate continuePredicate) { *

* @return a new {@link Mono} representing the termination of this {@link Flux} */ - public final Mono then() { + public final Mono<@NonNull Void> then() { @SuppressWarnings("unchecked") Mono then = (Mono) new MonoIgnoreElements<>(this); return Mono.onAssembly(then); @@ -6841,7 +6842,7 @@ public final Mono then() { * * @return a new {@link Flux} that wait for source completion then emits from the supplied {@link Mono} */ - public final Mono then(Mono other) { + public final Mono<@NonNull V> then(Mono<@NonNull V> other) { return Mono.onAssembly(new MonoIgnoreThen<>(new Publisher[] { this }, other)); } @@ -6857,7 +6858,7 @@ public final Mono then(Mono other) { * @return a new {@link Mono} completing when both publishers have completed in * sequence */ - public final Mono thenEmpty(Publisher other) { + public final Mono<@NonNull Void> thenEmpty(Publisher<@NonNull Void> other) { return then(Mono.fromDirect(other)); } @@ -6875,7 +6876,7 @@ public final Mono thenEmpty(Publisher other) { * @return a new {@link Flux} that emits from the supplied {@link Publisher} after * this Flux completes. */ - public final Flux thenMany(Publisher other) { + public final Flux<@NonNull V> thenMany(Publisher<@NonNull V> other) { if (this instanceof FluxConcatArray) { @SuppressWarnings({ "unchecked" }) FluxConcatArray fluxConcatArray = (FluxConcatArray) this; @@ -6898,7 +6899,7 @@ public final Flux thenMany(Publisher other) { * * @return a {@link Flux} that can time out on a per-item basis */ - public final Flux timeout(Duration timeout) { + public final Flux<@NonNull T> timeout(Duration timeout) { return timeout(timeout, null, Schedulers.parallel()); } @@ -6916,7 +6917,7 @@ public final Flux timeout(Duration timeout) { * * @return a {@link Flux} that will fallback to a different {@link Publisher} in case of a per-item timeout */ - public final Flux timeout(Duration timeout, @Nullable Publisher fallback) { + public final Flux<@NonNull T> timeout(Duration timeout, @Nullable Publisher fallback) { return timeout(timeout, fallback, Schedulers.parallel()); } @@ -6933,7 +6934,7 @@ public final Flux timeout(Duration timeout, @Nullable Publisher * * @return a {@link Flux} that can time out on a per-item basis */ - public final Flux timeout(Duration timeout, Scheduler timer) { + public final Flux<@NonNull T> timeout(Duration timeout, Scheduler timer) { return timeout(timeout, null, timer); } @@ -6953,8 +6954,8 @@ public final Flux timeout(Duration timeout, Scheduler timer) { * * @return a {@link Flux} that will fallback to a different {@link Publisher} in case of a per-item timeout */ - public final Flux timeout(Duration timeout, - @Nullable Publisher fallback, + public final Flux<@NonNull T> timeout(Duration timeout, + @Nullable Publisher fallback, Scheduler timer) { final Mono _timer = Mono.delay(timeout, timer).onErrorReturn(0L); final Function> rest = o -> _timer; @@ -6981,7 +6982,7 @@ public final Flux timeout(Duration timeout, * a signal from a companion {@link Publisher} * */ - public final Flux timeout(Publisher firstTimeout) { + public final Flux<@NonNull T> timeout(Publisher<@NonNull U> firstTimeout) { return timeout(firstTimeout, t -> never()); } @@ -7003,8 +7004,8 @@ public final Flux timeout(Publisher firstTimeout) { * @return a {@link Flux} that can time out if each element does not come before * a signal from a per-item companion {@link Publisher} */ - public final Flux timeout(Publisher firstTimeout, - Function> nextTimeoutFactory) { + public final Flux<@NonNull T> timeout(Publisher<@NonNull U> firstTimeout, + Function> nextTimeoutFactory) { return onAssembly(new FluxTimeout<>(this, firstTimeout, nextTimeoutFactory)); } @@ -7027,8 +7028,8 @@ public final Flux timeout(Publisher firstTimeout, * @return a {@link Flux} that can time out if each element does not come before * a signal from a per-item companion {@link Publisher} */ - public final Flux timeout(Publisher firstTimeout, - Function> nextTimeoutFactory, Publisher + public final Flux<@NonNull T> timeout(Publisher<@NonNull U> firstTimeout, + Function> nextTimeoutFactory, Publisher fallback) { return onAssembly(new FluxTimeout<>(this, firstTimeout, nextTimeoutFactory, fallback)); @@ -7044,7 +7045,7 @@ public final Flux timeout(Publisher firstTimeout, * * @return a timestamped {@link Flux} */ - public final Flux> timestamp() { + public final Flux<@NonNull Tuple2<@NonNull Long, @NonNull T>> timestamp() { return timestamp(Schedulers.parallel()); } @@ -7059,7 +7060,7 @@ public final Flux> timestamp() { * @param scheduler the {@link Scheduler} to read time from * @return a timestamped {@link Flux} */ - public final Flux> timestamp(Scheduler scheduler) { + public final Flux<@NonNull Tuple2<@NonNull Long, @NonNull T>> timestamp(Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler"); return map(d -> Tuples.of(scheduler.now(TimeUnit.MILLISECONDS), d)); } @@ -7074,7 +7075,7 @@ public final Flux> timestamp(Scheduler scheduler) { * * @return a blocking {@link Iterable} */ - public final Iterable toIterable() { + public final Iterable<@NonNull T> toIterable() { return toIterable(Queues.SMALL_BUFFER_SIZE); } @@ -7091,7 +7092,7 @@ public final Iterable toIterable() { * * @return a blocking {@link Iterable} */ - public final Iterable toIterable(int batchSize) { + public final Iterable<@NonNull T> toIterable(int batchSize) { return toIterable(batchSize, null); } @@ -7109,8 +7110,7 @@ public final Iterable toIterable(int batchSize) { * * @return a blocking {@link Iterable} */ - public final Iterable toIterable(int batchSize, @Nullable Supplier> - queueProvider) { + public final Iterable<@NonNull T> toIterable(int batchSize, @Nullable Supplier<@NonNull Queue<@NonNull T>> queueProvider) { final Supplier> provider; if(queueProvider == null){ provider = Queues.get(batchSize); @@ -7130,7 +7130,7 @@ public final Iterable toIterable(int batchSize, @Nullable Supplier> * * @return a {@link Stream} of unknown size with onClose attached to {@link Subscription#cancel()} */ - public final Stream toStream() { + public final Stream<@NonNull T> toStream() { return toStream(Queues.SMALL_BUFFER_SIZE); } @@ -7145,7 +7145,7 @@ public final Stream toStream() { * * @return a {@link Stream} of unknown size with onClose attached to {@link Subscription#cancel()} */ - public final Stream toStream(int batchSize) { + public final Stream<@NonNull T> toStream(int batchSize) { final Supplier> provider; provider = Queues.get(batchSize); return new BlockingIterable<>(this, batchSize, provider).stream(); @@ -7170,7 +7170,7 @@ public final Stream toStream(int batchSize) { * @see #compose(Function) for deferred composition of {@link Flux} for each {@link Subscriber} * @see #as for a loose conversion to an arbitrary type */ - public final Flux transform(Function, ? extends Publisher> transformer) { + public final Flux<@NonNull V> transform(Function, ? extends @NonNull Publisher<@NonNull V>> transformer) { return onAssembly(from(transformer.apply(this))); } @@ -7186,7 +7186,7 @@ public final Flux transform(Function, ? extends Publisher * * @return a {@link Flux} of {@link Flux} windows based on element count */ - public final Flux> window(int maxSize) { + public final Flux<@NonNull Flux<@NonNull T>> window(int maxSize) { return onAssembly(new FluxWindow<>(this, maxSize, Queues.get(maxSize))); } @@ -7212,7 +7212,7 @@ public final Flux> window(int maxSize) { * * @return a {@link Flux} of {@link Flux} windows based on element count and opened every skipCount */ - public final Flux> window(int maxSize, int skip) { + public final Flux<@NonNull Flux<@NonNull T>> window(int maxSize, int skip) { return onAssembly(new FluxWindow<>(this, maxSize, skip, @@ -7231,7 +7231,7 @@ public final Flux> window(int maxSize, int skip) { * * @return a {@link Flux} of {@link Flux} windows delimited by a given {@link Publisher} */ - public final Flux> window(Publisher boundary) { + public final Flux<@NonNull Flux<@NonNull T>> window(Publisher<@NonNull ?> boundary) { return onAssembly(new FluxWindowBoundary<>(this, boundary, Queues.unbounded(Queues.XS_BUFFER_SIZE), @@ -7250,7 +7250,7 @@ public final Flux> window(Publisher boundary) { * * @return a {@link Flux} of {@link Flux} windows continuously opened for a given {@link Duration} */ - public final Flux> window(Duration timespan) { + public final Flux<@NonNull Flux<@NonNull T>> window(Duration timespan) { return window(timespan, Schedulers.parallel()); } @@ -7281,7 +7281,7 @@ public final Flux> window(Duration timespan) { * closed after a {@link Duration} * */ - public final Flux> window(Duration timespan, Duration timeshift) { + public final Flux<@NonNull Flux<@NonNull T>> window(Duration timespan, Duration timeshift) { return window(timespan, timeshift, Schedulers.parallel()); } @@ -7297,7 +7297,7 @@ public final Flux> window(Duration timespan, Duration timeshift) { * * @return a {@link Flux} of {@link Flux} windows continuously opened for a given {@link Duration} */ - public final Flux> window(Duration timespan, Scheduler timer) { + public final Flux<@NonNull Flux<@NonNull T>> window(Duration timespan, Scheduler timer) { return window(interval(timespan, timer)); } @@ -7328,7 +7328,7 @@ public final Flux> window(Duration timespan, Scheduler timer) { * @return a {@link Flux} of {@link Flux} windows opened at regular intervals and * closed after a {@link Duration} */ - public final Flux> window(Duration timespan, Duration timeshift, Scheduler timer) { + public final Flux<@NonNull Flux<@NonNull T>> window(Duration timespan, Duration timeshift, Scheduler timer) { if (timeshift.equals(timespan)) { return window(timespan); } @@ -7350,7 +7350,7 @@ public final Flux> window(Duration timespan, Duration timeshift, Schedul * * @return a {@link Flux} of {@link Flux} windows based on element count and duration */ - public final Flux> windowTimeout(int maxSize, Duration timespan) { + public final Flux<@NonNull Flux<@NonNull T>> windowTimeout(int maxSize, Duration timespan) { return windowTimeout(maxSize, timespan , Schedulers.parallel()); } @@ -7370,7 +7370,7 @@ public final Flux> windowTimeout(int maxSize, Duration timespan) { * * @return a {@link Flux} of {@link Flux} windows based on element count and duration */ - public final Flux> windowTimeout(int maxSize, Duration timespan, Scheduler timer) { + public final Flux<@NonNull Flux<@NonNull T>> windowTimeout(int maxSize, Duration timespan, Scheduler timer) { return onAssembly(new FluxWindowTimeOrSize<>(this, maxSize, timespan.toMillis(), timer)); } @@ -7386,7 +7386,7 @@ public final Flux> windowTimeout(int maxSize, Duration timespan, Schedul * @return a {@link Flux} of {@link Flux} windows, bounded depending * on the predicate. */ - public final Flux> windowUntil(Predicate boundaryTrigger) { + public final Flux<@NonNull Flux<@NonNull T>> windowUntil(Predicate<@NonNull T> boundaryTrigger) { return windowUntil(boundaryTrigger, false); } @@ -7411,7 +7411,7 @@ public final Flux> windowUntil(Predicate boundaryTrigger) { * @return a {@link Flux} of {@link Flux} windows, bounded depending * on the predicate. */ - public final Flux> windowUntil(Predicate boundaryTrigger, boolean cutBefore) { + public final Flux<@NonNull Flux<@NonNull T>> windowUntil(Predicate<@NonNull T> boundaryTrigger, boolean cutBefore) { return windowUntil(boundaryTrigger, cutBefore, Queues.SMALL_BUFFER_SIZE); } @@ -7438,7 +7438,7 @@ public final Flux> windowUntil(Predicate boundaryTrigger, boolean cut * @return a {@link Flux} of {@link Flux} windows, bounded depending * on the predicate. */ - public final Flux> windowUntil(Predicate boundaryTrigger, boolean cutBefore, int prefetch) { + public final Flux<@NonNull Flux<@NonNull T>> windowUntil(Predicate<@NonNull T> boundaryTrigger, boolean cutBefore, int prefetch) { return onAssembly(new FluxWindowPredicate<>(this, Queues.unbounded(prefetch), Queues.unbounded(prefetch), @@ -7462,7 +7462,7 @@ public final Flux> windowUntil(Predicate boundaryTrigger, boolean cut * @return a {@link Flux} of {@link Flux} windows, each containing * subsequent elements that all passed a predicate. */ - public final Flux> windowWhile(Predicate inclusionPredicate) { + public final Flux<@NonNull Flux<@NonNull T>> windowWhile(Predicate<@NonNull T> inclusionPredicate) { return windowWhile(inclusionPredicate, Queues.SMALL_BUFFER_SIZE); } @@ -7482,7 +7482,7 @@ public final Flux> windowWhile(Predicate inclusionPredicate) { * @return a {@link Flux} of {@link Flux} windows, each containing * subsequent elements that all passed a predicate. */ - public final Flux> windowWhile(Predicate inclusionPredicate, int prefetch) { + public final Flux<@NonNull Flux<@NonNull T>> windowWhile(Predicate<@NonNull T> inclusionPredicate, int prefetch) { return onAssembly(new FluxWindowPredicate<>(this, Queues.unbounded(prefetch), Queues.unbounded(prefetch), @@ -7518,8 +7518,8 @@ public final Flux> windowWhile(Predicate inclusionPredicate, int pref * @return a {@link Flux} of {@link Flux} windows opened by signals from a first * {@link Publisher} and lasting until a selected second {@link Publisher} emits */ - public final Flux> windowWhen(Publisher bucketOpening, - final Function> closeSelector) { + public final Flux<@NonNull Flux<@NonNull T>> windowWhen(Publisher<@NonNull U> bucketOpening, + final Function> closeSelector) { return onAssembly(new FluxWindowWhen<>(this, bucketOpening, closeSelector, @@ -7548,8 +7548,8 @@ public final Flux> windowWhen(Publisher bucketOpening, * * @return a combined {@link Flux} gated by another {@link Publisher} */ - public final Flux withLatestFrom(Publisher other, BiFunction resultSelector){ + public final Flux<@NonNull R> withLatestFrom(Publisher other, BiFunction resultSelector){ return onAssembly(new FluxWithLatestFrom<>(this, other, resultSelector)); } @@ -7568,7 +7568,7 @@ public final Flux withLatestFrom(Publisher other, BiFunct * @return a zipped {@link Flux} * */ - public final Flux> zipWith(Publisher source2) { + public final Flux<@NonNull Tuple2<@NonNull T, @NonNull T2>> zipWith(Publisher source2) { return zipWith(source2, tuple2Function()); } @@ -7590,8 +7590,8 @@ public final Flux> zipWith(Publisher source2) { * * @return a zipped {@link Flux} */ - public final Flux zipWith(Publisher source2, - final BiFunction combinator) { + public final Flux<@NonNull V> zipWith(Publisher source2, + final BiFunction combinator) { if (this instanceof FluxZip) { @SuppressWarnings("unchecked") FluxZip o = (FluxZip) this; @@ -7623,9 +7623,9 @@ public final Flux zipWith(Publisher source2, * @return a zipped {@link Flux} */ @SuppressWarnings("unchecked") - public final Flux zipWith(Publisher source2, + public final Flux<@NonNull V> zipWith(Publisher source2, int prefetch, - BiFunction combinator) { + BiFunction combinator) { return zip(objects -> combinator.apply((T) objects[0], (T2) objects[1]), prefetch, this, @@ -7648,7 +7648,7 @@ public final Flux zipWith(Publisher source2, * * @return a zipped {@link Flux} */ - public final Flux> zipWith(Publisher source2, int prefetch) { + public final Flux<@NonNull Tuple2<@NonNull T, @NonNull T2>> zipWith(Publisher source2, int prefetch) { return zipWith(source2, prefetch, tuple2Function()); } @@ -7666,7 +7666,7 @@ public final Flux> zipWith(Publisher source2, i * */ @SuppressWarnings("unchecked") - public final Flux> zipWithIterable(Iterable iterable) { + public final Flux<@NonNull Tuple2<@NonNull T, @NonNull T2>> zipWithIterable(Iterable iterable) { return zipWithIterable(iterable, tuple2Function()); } @@ -7687,8 +7687,8 @@ public final Flux> zipWithIterable(Iterable ite * @return a zipped {@link Flux} * */ - public final Flux zipWithIterable(Iterable iterable, - BiFunction zipper) { + public final Flux<@NonNull V> zipWithIterable(Iterable iterable, + BiFunction zipper) { return onAssembly(new FluxZipIterable<>(this, iterable, zipper)); } @@ -7704,7 +7704,7 @@ public final Flux zipWithIterable(Iterable iterable, * @return the source, potentially wrapped with assembly time cross-cutting behavior */ @SuppressWarnings("unchecked") - protected static Flux onAssembly(Flux source) { + protected static Flux<@NonNull T> onAssembly(Flux<@NonNull T> source) { Function hook = Hooks.onEachOperatorHook; if(hook == null) { return source; @@ -7724,7 +7724,7 @@ protected static Flux onAssembly(Flux source) { * @return the source, potentially wrapped with assembly time cross-cutting behavior */ @SuppressWarnings("unchecked") - protected static Flux onLastAssembly(Flux source) { + protected static Flux<@NonNull T> onLastAssembly(Flux<@NonNull T> source) { Function hook = Hooks.onLastOperatorHook; if(hook == null) { return source; @@ -7744,7 +7744,7 @@ protected static Flux onLastAssembly(Flux source) { * @return the source, potentially wrapped with assembly time cross-cutting behavior */ @SuppressWarnings("unchecked") - protected static ConnectableFlux onAssembly(ConnectableFlux source) { + protected static ConnectableFlux<@NonNull T> onAssembly(ConnectableFlux<@NonNull T> source) { Function hook = Hooks.onEachOperatorHook; if(hook == null) { return source; @@ -7758,8 +7758,8 @@ public String toString() { } - final Flux flatMap(Function> mapper, boolean delayError, int concurrency, int prefetch) { + final Flux<@NonNull V> flatMap(Function> mapper, boolean delayError, int concurrency, int prefetch) { return onAssembly(new FluxFlatMap<>( this, mapper, @@ -7771,8 +7771,8 @@ final Flux flatMap(Function Flux flatMapSequential(Function> mapper, boolean delayError, int maxConcurrency, + final Flux<@NonNull R> flatMapSequential(Function> mapper, boolean delayError, int maxConcurrency, int prefetch) { return onAssembly(new FluxMergeSequential<>(this, mapper, maxConcurrency, prefetch, delayError ? FluxConcatMap.ErrorMode.END : @@ -7780,10 +7780,10 @@ final Flux flatMapSequential(Function Flux doOnSignal(Flux source, - @Nullable Consumer onSubscribe, - @Nullable Consumer onNext, - @Nullable Consumer onError, + static Flux<@NonNull T> doOnSignal(Flux<@NonNull T> source, + @Nullable Consumer onSubscribe, + @Nullable Consumer onNext, + @Nullable Consumer onError, @Nullable Runnable onComplete, @Nullable Runnable onAfterTerminate, @Nullable LongConsumer onRequest, @@ -7815,7 +7815,7 @@ static Flux doOnSignal(Flux source, * * @return the mono representing that Flux */ - static Mono convertToMono(Callable supplier) { + static Mono<@NonNull T> convertToMono(Callable<@Nullable T> supplier) { if (supplier instanceof Fuseable.ScalarCallable) { Fuseable.ScalarCallable scalarCallable = (Fuseable.ScalarCallable) supplier; @@ -7835,7 +7835,7 @@ static Mono convertToMono(Callable supplier) { } @SafeVarargs - static Flux merge(int prefetch, boolean delayError, Publisher... sources) { + static Flux<@NonNull I> merge(int prefetch, boolean delayError, Publisher @NonNull ... sources) { if (sources.length == 0) { return empty(); } @@ -7851,8 +7851,8 @@ static Flux merge(int prefetch, boolean delayError, Publisher Flux mergeSequential(int prefetch, boolean delayError, - Publisher... sources) { + static Flux<@NonNull I> mergeSequential(int prefetch, boolean delayError, + Publisher @NonNull ... sources) { if (sources.length == 0) { return empty(); } @@ -7864,7 +7864,7 @@ static Flux mergeSequential(int prefetch, boolean delayError, delayError ? FluxConcatMap.ErrorMode.END : FluxConcatMap.ErrorMode.IMMEDIATE)); } - static Flux mergeSequential(Publisher> sources, + static Flux<@NonNull T> mergeSequential(Publisher> sources, boolean delayError, int maxConcurrency, int prefetch) { return onAssembly(new FluxMergeSequential<>(from(sources), identityFunction(), @@ -7872,7 +7872,7 @@ static Flux mergeSequential(Publisher> s FluxConcatMap.ErrorMode.IMMEDIATE)); } - static Flux mergeSequential(Iterable> sources, + static Flux<@NonNull I> mergeSequential(Iterable> sources, boolean delayError, int maxConcurrency, int prefetch) { return onAssembly(new FluxMergeSequential<>(new FluxIterable<>(sources), identityFunction(), maxConcurrency, prefetch, @@ -7894,7 +7894,7 @@ public boolean getAsBoolean() { }; } - static Predicate countingPredicate(Predicate predicate, long max) { + static Predicate<@NonNull O> countingPredicate(Predicate<@NonNull O> predicate, long max) { if (max == 0) { return predicate; } @@ -7909,32 +7909,32 @@ public boolean test(O o) { } @SuppressWarnings("unchecked") - static Supplier> hashSetSupplier() { + static Supplier<@NonNull Set<@NonNull O>> hashSetSupplier() { return SET_SUPPLIER; } @SuppressWarnings("unchecked") - static Supplier> listSupplier() { + static Supplier<@NonNull List<@NonNull O>> listSupplier() { return LIST_SUPPLIER; } @SuppressWarnings("unchecked") - static Function hashcodeSupplier() { + static Function<@NonNull U, @NonNull V> hashcodeSupplier() { return HASHCODE_EXTRACTOR; } @SuppressWarnings("unchecked") - static BiPredicate equalPredicate() { + static BiPredicate<@NonNull U, @NonNull V> equalPredicate() { return OBJECT_EQUAL; } @SuppressWarnings("unchecked") - static Function identityFunction(){ + static Function<@NonNull T, @NonNull T> identityFunction(){ return IDENTITY_FUNCTION; } @SuppressWarnings("unchecked") - static BiFunction> tuple2Function() { + static BiFunction<@NonNull A, @NonNull B, @NonNull Tuple2<@NonNull A, @NonNull B>> tuple2Function() { return TUPLE2_BIFUNCTION; } @@ -7946,7 +7946,7 @@ static BiFunction> tuple2Function() { * @return a wrapped {@link Flux} */ @SuppressWarnings("unchecked") - static Flux wrap(Publisher source){ + static Flux<@NonNull I> wrap(Publisher source){ if(source instanceof Mono){ if(source instanceof Fuseable){ return new FluxSourceMonoFuseable<>((Mono)source); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxArray.java b/reactor-core/src/main/java/reactor/core/publisher/FluxArray.java index 0ee5e43634..23437ba898 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxArray.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxArray.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits the contents of a wrapped (shared) array. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnect.java b/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnect.java index 1e14b83a4d..5005634f9c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnect.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Connects to the underlying Flux once the given amount of Subscribers diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnectFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnectFuseable.java index 45dbeb5bf2..1cedeb35f3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnectFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxAutoConnectFuseable.java @@ -18,12 +18,12 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Connects to the underlying Flux once the given amount of Subscribers diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java index c0193745b5..d3ea5ec1ec 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java @@ -23,10 +23,10 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.BooleanSupplier; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Buffers a certain number of subsequent elements and emits the buffers. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java index 2b9114bd2f..b5be7dce21 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java @@ -21,13 +21,13 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Buffers elements into custom collections where the buffer boundary is signalled diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java index 9e7d27b3d6..ab6ee3e99c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java @@ -25,12 +25,12 @@ import java.util.function.BooleanSupplier; import java.util.function.Predicate; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable.ConditionalSubscriber; +import reactor.util.annotation.Nullable; /** * Buffers elements into custom collections where the buffer boundary is determined by diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java index 0d3d4efc1f..7f8609cff0 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java @@ -23,13 +23,13 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java index ad84c26e3c..daeacdebf2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java @@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -36,6 +35,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * buffers elements into possibly overlapping buffers whose boundaries are determined diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java index b5a9fbd7e3..03a688c129 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java @@ -19,11 +19,11 @@ import java.util.Objects; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; final class FluxCancelOn extends FluxOperator { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java index 84fa7658c2..85c377ce9c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java @@ -25,7 +25,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -35,6 +34,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Combines the latest values from multiple sources through a function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java index 1cc95616ca..3fedb207c3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; +import reactor.util.annotation.Nullable; /** * Concatenates a fixed array of Publishers' values. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java index 5a8d739bdf..8915713abc 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -31,6 +30,7 @@ import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; import static reactor.core.Exceptions.TERMINATED; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java b/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java index d552278a14..7e83918ab9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java @@ -18,12 +18,12 @@ import java.util.Objects; import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; final class FluxContextStart extends FluxOperator implements Fuseable { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java index e14e4dd0d7..98c967fc40 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java @@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; @@ -35,6 +34,7 @@ import reactor.core.publisher.FluxSink.OverflowStrategy; import reactor.util.concurrent.Queues; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Provides a multi-valued sink API for a callback that is called for each individual diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDefaultIfEmpty.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDefaultIfEmpty.java index c87a0e72d5..a934f12179 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDefaultIfEmpty.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDefaultIfEmpty.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits a scalar value if the source sequence turns out to be empty. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java index 01def6184b..b069a51388 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java @@ -17,12 +17,12 @@ import java.util.Objects; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Delays the subscription to the main source until another Publisher diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java index e51b7cefe4..ff61c3ac46 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java @@ -20,10 +20,10 @@ import java.util.Iterator; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.BooleanSupplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDetach.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDetach.java index 5e451e7781..2d6c1baefb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDetach.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDetach.java @@ -15,11 +15,11 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Detaches the both the child Subscriber and the Subscription on diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java index 6062b62702..b6b4a72c06 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java @@ -20,13 +20,13 @@ import java.util.Objects; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Fuseable.ConditionalSubscriber; import reactor.core.Fuseable.QueueSubscription; +import reactor.util.annotation.Nullable; /** * For each subscriber, tracks the source values that have been seen and diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java index 9be316b2de..7ec156ab8d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.function.BiPredicate; import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable.ConditionalSubscriber; +import reactor.util.annotation.Nullable; /** * Filters out subsequent and repeated elements. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java index d2d62684aa..0757e5fb50 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java @@ -18,7 +18,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; @@ -26,6 +25,7 @@ import reactor.core.Fuseable; import reactor.core.Fuseable.ConditionalSubscriber; import reactor.core.Fuseable.QueueSubscription; +import reactor.util.annotation.Nullable; /** * Hook into the lifecycle events and signals of a {@link Flux} and execute diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java index a7d82c28c1..a54539abe7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; +import reactor.util.annotation.Nullable; /** * Peek into the lifecycle events and signals of a sequence diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxElapsed.java b/reactor-core/src/main/java/reactor/core/publisher/FluxElapsed.java index b3a59ce4b3..812205c988 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxElapsed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxElapsed.java @@ -17,7 +17,6 @@ package reactor.core.publisher; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; @@ -25,6 +24,7 @@ import reactor.core.scheduler.Scheduler; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxEmpty.java b/reactor-core/src/main/java/reactor/core/publisher/FluxEmpty.java index e28bee6f1d..8e3cf03c6b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxEmpty.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxEmpty.java @@ -15,10 +15,10 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Represents an empty publisher which only calls onSubscribe and onComplete. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxErrorOnRequest.java b/reactor-core/src/main/java/reactor/core/publisher/FluxErrorOnRequest.java index c605afdb7d..94d9160fd7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxErrorOnRequest.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxErrorOnRequest.java @@ -18,10 +18,9 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import javax.annotation.Nullable; -import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Emits a constant or generated Throwable instance to Subscribers. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java index a1eb150dd2..f6f789a3cc 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java @@ -18,12 +18,12 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Fuseable.ConditionalSubscriber; +import reactor.util.annotation.Nullable; /** * Filters out values that make a filter function return false. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java index e4123c536f..f8674cae54 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Filters out values that make a filter function return false. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java index d826e514db..ad1fc10e4e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java @@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -34,6 +33,7 @@ import reactor.core.Scannable; import reactor.util.concurrent.Queues; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Maps each upstream value into a single {@code true} or {@code false} value provided by diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java index 275ebe97d4..cc9c9b9c08 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java @@ -20,12 +20,12 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Given a push of source Publishers the values of that Publisher is forwarded to the diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java index 473319b96e..4dee8efef2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java @@ -25,7 +25,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -35,6 +34,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Maps a sequence of values each into a Publisher and flattens them diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java index e98b1c1fdf..4dd463b6af 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java @@ -25,13 +25,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Concatenates values from Iterable sequences generated via a mapper function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFromMonoOperator.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFromMonoOperator.java index a30b159d1d..4a31a5dd91 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFromMonoOperator.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFromMonoOperator.java @@ -17,10 +17,10 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A decorating {@link Flux} {@link Publisher} that exposes {@link Flux} API over an diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java index a716ca3d91..c716fba696 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java @@ -20,12 +20,12 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.BiFunction; import java.util.function.Consumer; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Generate signals one-by-one via a function callback. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java index af378674ce..664239e514 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java @@ -26,7 +26,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -35,6 +34,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Groups upstream items into their own Publisher sequence based on a key selector. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java index 2d1da397c2..396ae942f5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java @@ -28,7 +28,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -39,6 +38,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * A Publisher that correlates two Publishers when they overlap in time and groups the diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java index b71cb1abd8..7887cca0ac 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java @@ -17,12 +17,12 @@ import java.util.Objects; import java.util.function.BiConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Maps the values of the source publisher one-on-one via a handler function as long as the handler function result is diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java index f835433b33..23d532ce63 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java @@ -18,13 +18,13 @@ import java.util.Objects; import java.util.function.BiConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Maps the values of the source publisher one-on-one via a handler function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHide.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHide.java index 5c667bd4d0..37bdf9b696 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHide.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHide.java @@ -15,11 +15,11 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Hides the identities of the upstream Publisher object and its Subscription diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java b/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java index 52b189545e..0bd715fe23 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java @@ -19,13 +19,13 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Scheduler.Worker; +import reactor.util.annotation.Nullable; /** * Periodically emits an ever increasing long value either via a ScheduledExecutorService diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java index c44544ad74..aa451b4bd9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java @@ -19,11 +19,11 @@ import java.util.Iterator; import java.util.Objects; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits the contents of an Iterable source. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java b/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java index d27fbf7c90..e063b6b99c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java @@ -28,7 +28,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -40,6 +39,7 @@ import reactor.core.publisher.FluxGroupJoin.JoinSupport; import reactor.core.publisher.FluxGroupJoin.LeftRightEndSubscriber; import reactor.core.publisher.FluxGroupJoin.LeftRightSubscriber; +import reactor.util.annotation.Nullable; /** * @see https://github.com/reactor/reactive-streams-commons diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxJust.java b/reactor-core/src/main/java/reactor/core/publisher/FluxJust.java index 3f66220254..0864b72657 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxJust.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxJust.java @@ -17,11 +17,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * A Stream that emits only one value and then complete. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java index abe66feacd..7cc3f33bca 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Maps the values of the source publisher one-on-one via a mapper function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java index 283c7073a6..39d62eb5c8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Maps the values of the source publisher one-on-one via a mapper function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java index a30f627efc..2857a62c39 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java @@ -22,10 +22,10 @@ import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Maps the values of the source publisher one-on-one via a mapper function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java index 484951942f..873281162c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java @@ -20,10 +20,10 @@ import java.util.Iterator; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.BooleanSupplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java index b4ab67a334..1a45408c72 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java @@ -24,7 +24,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -37,6 +36,7 @@ import reactor.core.publisher.FluxConcatMap.ErrorMode; import reactor.util.concurrent.Queues; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Maps each upstream value into a Publisher and concatenates them into one diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxName.java b/reactor-core/src/main/java/reactor/core/publisher/FluxName.java index 9493f7e1a1..f3145db8f6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxName.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxName.java @@ -20,12 +20,12 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import reactor.util.annotation.Nullable; /** * An operator that just bears a name or a set of tags, which can be retrieved via the diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxNameFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxNameFuseable.java index 3b1ac097af..159bc02eac 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxNameFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxNameFuseable.java @@ -17,11 +17,11 @@ package reactor.core.publisher; import java.util.Set; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.util.function.Tuple2; +import reactor.util.annotation.Nullable; /** * An operator that just bears a name or a set of tags, which can be retrieved via the diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnAssembly.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnAssembly.java index bd5ba6eca2..43f25b3c5e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnAssembly.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnAssembly.java @@ -17,7 +17,6 @@ import java.util.LinkedList; import java.util.List; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -27,6 +26,7 @@ import reactor.core.Scannable; import reactor.util.function.Tuple3; import reactor.util.function.Tuples; +import reactor.util.annotation.Nullable; /** * Captures the current stacktrace when this publisher is created and diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java index 637cc324bb..5e5b24c719 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java @@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -28,6 +27,7 @@ import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.util.concurrent.Queues; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java index 7bc5a7bacd..7284fe33d4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java @@ -20,12 +20,12 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; +import reactor.util.annotation.Nullable; /** * Buffers values if the subscriber doesn't request fast enough, bounding the diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java index 8d451a4f1c..4aa29c443c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java @@ -24,13 +24,13 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.scheduler.Scheduler; import reactor.util.Logger; import reactor.util.Loggers; +import reactor.util.annotation.Nullable; /** * Buffers values if the subscriber doesn't request fast enough, bounding the buffer to a diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java index b8342757dd..154ef482e6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java @@ -19,10 +19,10 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Drops values if the subscriber doesn't request fast enough. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureLatest.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureLatest.java index aa58bcf064..94a2366ade 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureLatest.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureLatest.java @@ -18,11 +18,11 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Runs the source in unbounded mode and emits only the latest value diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOperator.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOperator.java index be0128ef74..917c8fb9ed 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOperator.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOperator.java @@ -17,13 +17,10 @@ package reactor.core.publisher; import java.util.Objects; -import java.util.function.BiFunction; -import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; -import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A decorating {@link Flux} {@link Publisher} that exposes {@link Flux} API over an diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java index e5c486b16e..bf80da1c88 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java @@ -17,7 +17,6 @@ import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; @@ -25,6 +24,7 @@ import reactor.core.Fuseable.ConditionalSubscriber; import reactor.core.publisher.FluxPeekFuseable.PeekConditionalSubscriber; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Peek into the lifecycle events and signals of a sequence. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java index 735140db3e..29bb662ddf 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java @@ -18,13 +18,13 @@ import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Peek into the lifecycle events and signals of a sequence. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/FluxProcessor.java index 2b91d7614d..3ee3bb54c7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxProcessor.java @@ -19,7 +19,6 @@ import java.util.Objects; import java.util.concurrent.CancellationException; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Processor; import org.reactivestreams.Publisher; @@ -27,6 +26,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A base processor that exposes {@link Flux} API for {@link Processor}. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java index b766c10429..77ca8695aa 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java @@ -25,7 +25,6 @@ import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; @@ -33,6 +32,7 @@ import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A connectable publisher which shares an underlying source and dispatches source values diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java index 21c3352de3..7f7b8fe8be 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java @@ -24,7 +24,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -33,6 +32,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Shares a sequence for the duration of a function that may transform it and diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java index 24b492d4f8..35e1964727 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -31,6 +30,7 @@ import reactor.core.Fuseable; import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Scheduler.Worker; +import reactor.util.annotation.Nullable; /** * Emits events on a different thread specified by a scheduler callback. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRange.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRange.java index 7c7980dd16..7179c53c0b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRange.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRange.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits a range of integer values. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRefCount.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRefCount.java index ae048ad616..e5faf135b2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRefCount.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRefCount.java @@ -19,13 +19,13 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Connects to the underlying Flux once the given number of Subscribers subscribed diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRefCountGrace.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRefCountGrace.java index 94f0140660..a44d90603b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRefCountGrace.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRefCountGrace.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; @@ -30,6 +29,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * @author Simon Baslé diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java index 579176e787..6850122a17 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java @@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -28,6 +27,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Repeats a source when a companion sequence signals an item in response to the main's diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java b/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java index edef02f606..cf5cf86f33 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java @@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -36,6 +35,7 @@ import reactor.core.Scannable; import reactor.core.scheduler.Scheduler; import reactor.util.concurrent.Queues; +import reactor.util.annotation.Nullable; /** * @param diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java index 7f8dd0d7d5..9107e5b406 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java @@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -27,6 +26,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * retries a source when a companion sequence signals diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSample.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSample.java index 6ce97a881a..12c8ca6e51 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSample.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSample.java @@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -27,6 +26,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Samples the main source and emits its latest value whenever the other Publisher diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java index 1e117d1190..f10cd615ac 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -30,6 +29,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Takes a value from upstream then uses the duration provided by a diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java index d5b21b7276..3f5550280f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java @@ -24,7 +24,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -33,6 +32,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Emits the last value from upstream only if there were no newer values emitted diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java b/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java index 45eea53037..1744aa42ce 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java @@ -17,10 +17,10 @@ import java.util.Objects; import java.util.function.BiFunction; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Accumulates the source values with an accumulator function and diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java b/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java index bd61fe5e48..cef32538c9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java @@ -20,10 +20,10 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.BiFunction; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Aggregates the source values with the help of an accumulator function diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkip.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkip.java index 4ef13fe3e5..c148c1c286 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkip.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkip.java @@ -15,10 +15,10 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Skips the first N elements from a reactive stream. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipLast.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipLast.java index da8bc13e56..d103bf09e9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipLast.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipLast.java @@ -16,10 +16,10 @@ package reactor.core.publisher; import java.util.ArrayDeque; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Skips the last N elements from the source stream. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java index 4a443e98b1..821c7f620b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java @@ -17,11 +17,11 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable.ConditionalSubscriber; +import reactor.util.annotation.Nullable; /** * Skips source values while a predicate returns diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java index f2618b4da5..463c3079c9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java @@ -19,13 +19,13 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Skips values from the main publisher until the other publisher signals diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java index 8b990a304e..10c5fb6a4f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java @@ -17,11 +17,11 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable.ConditionalSubscriber; +import reactor.util.annotation.Nullable; /** * Skips source values while a predicate returns diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSource.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSource.java index cbd05ee16d..ad9e6ae7a9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSource.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSource.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A connecting {@link Flux} Publisher (right-to-left from a composition chain perspective) diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSourceFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSourceFuseable.java index 5a27961fa5..78695c019a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSourceFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSourceFuseable.java @@ -16,12 +16,12 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java index 43d415eef5..09ec65ca0a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java @@ -19,13 +19,13 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Scheduler.Worker; +import reactor.util.annotation.Nullable; /** * Subscribes to the source Publisher asynchronously through a scheduler function or diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java index 764f3311b0..695643caad 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java @@ -21,12 +21,12 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Fuseable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * Executes a Callable and emits its value on the given Scheduler. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java index b8e1cfcbf9..1dec0363ec 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java @@ -20,7 +20,6 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import reactor.core.CoreSubscriber; @@ -29,6 +28,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * Publisher indicating a scalar/empty source that subscribes on the specified scheduler. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java index ebcc7bef76..cc4ea3f066 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java @@ -25,7 +25,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -34,6 +33,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Switches to a new Publisher generated via a function whenever the upstream produces an diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java index a4e4038232..9873214b74 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java @@ -16,13 +16,13 @@ package reactor.core.publisher; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Fuseable.ConditionalSubscriber; import reactor.core.Fuseable.QueueSubscription; +import reactor.util.annotation.Nullable; /** * Takes only the first N values from the source Publisher. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeLast.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeLast.java index e2c41e5544..18dba9c487 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeLast.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeLast.java @@ -19,10 +19,10 @@ import java.util.ArrayDeque; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.BooleanSupplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Emits the last N values the source emitted before its completion. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java index 93eda06550..90fc6d497a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java @@ -17,10 +17,10 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Relays values until a predicate returns diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntilOther.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntilOther.java index 371b6f4cf6..606a650e07 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntilOther.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntilOther.java @@ -18,13 +18,13 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Relays values from the main Publisher until another Publisher signals an event. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java index e099781e21..c7d740a6e6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java @@ -17,10 +17,10 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Relays values while a predicate returns diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java b/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java index 9ca81d879b..adaf61f8dd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java @@ -21,13 +21,13 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.function.Consumer; import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Uses a resource, generated by a supplier for each individual Subscriber, diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java index 3884cbefa8..88deaee670 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java @@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Processor; import org.reactivestreams.Subscriber; @@ -31,6 +30,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Splits the source sequence into possibly overlapping publishers. diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java index ff2639a135..3d46eb196d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -32,6 +31,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Splits the source sequence into continuous, non-overlapping windowEnds diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java index 5f8aa56e61..a025ce596b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java @@ -24,7 +24,6 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -33,6 +32,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.publisher.FluxBufferPredicate.Mode; +import reactor.util.annotation.Nullable; /** * Cut a sequence into non-overlapping windows where each window boundary is determined by diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java index 527cafb65e..3d86b63c3a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java @@ -21,13 +21,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * WindowTimeoutSubscriber is forwarding events on a steam until {@code maxSize} is reached, diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java index acd262c66c..b85e6913c3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java @@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -33,6 +32,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Exceptions; +import reactor.util.annotation.Nullable; /** * Splits the source sequence into potentially overlapping windowEnds controlled by items diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java index a2447b696e..b712f1b89f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java @@ -20,13 +20,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.BiFunction; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Combines values from a main Publisher with values from another diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java b/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java index 52dcaf7008..a66ad0b342 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java @@ -27,7 +27,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -37,6 +36,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; import static reactor.core.Fuseable.ASYNC; import static reactor.core.Fuseable.SYNC; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java index 75db019afb..fe270453f6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java @@ -19,10 +19,10 @@ import java.util.Iterator; import java.util.Objects; import java.util.function.BiFunction; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Pairwise combines elements of a publisher and an iterable sequence through a function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/GroupedFlux.java b/reactor-core/src/main/java/reactor/core/publisher/GroupedFlux.java index 60ce208659..2fd5f9f1ba 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/GroupedFlux.java +++ b/reactor-core/src/main/java/reactor/core/publisher/GroupedFlux.java @@ -15,7 +15,8 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; + +import reactor.util.annotation.Nullable; /** * Represents a sequence of events which has an associated key. diff --git a/reactor-core/src/main/java/reactor/core/publisher/Hooks.java b/reactor-core/src/main/java/reactor/core/publisher/Hooks.java index 50ee201148..7fa106d96c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Hooks.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Hooks.java @@ -26,13 +26,14 @@ import java.util.function.Consumer; import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.Exceptions; import reactor.util.Logger; import reactor.util.Loggers; import reactor.util.context.Context; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A push of overridable lifecycle hooks that can be used for cross-cutting @@ -65,7 +66,7 @@ public abstract class Hooks { * @see #resetOnEachOperator() * @see #onLastOperator(Function) */ - public static void onEachOperator(Function, ? extends Publisher> onEachOperator) { + public static void onEachOperator(Function, ? extends @NonNull Publisher<@NonNull Object>> onEachOperator) { onEachOperator(onEachOperator.toString(), onEachOperator); } @@ -94,7 +95,7 @@ public static void onEachOperator(Function, ? extends * @see #resetOnEachOperator() * @see #onLastOperator(String, Function) */ - public static void onEachOperator(String key, Function, ? extends Publisher> onEachOperator) { + public static void onEachOperator(String key, Function, ? extends @NonNull Publisher<@NonNull Object>> onEachOperator) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(onEachOperator, "onEachOperator"); log.debug("Hooking onEachOperator: {}", key); @@ -141,7 +142,7 @@ public static void resetOnEachOperator() { * * @param c the {@link Consumer} to apply to dropped errors */ - public static void onErrorDropped(Consumer c) { + public static void onErrorDropped(Consumer c) { Objects.requireNonNull(c, "onErrorDroppedHook"); log.debug("Hooking new default : onErrorDropped"); @@ -176,7 +177,7 @@ public static void onErrorDropped(Consumer c) { * @see #resetOnLastOperator() * @see #onEachOperator(Function) */ - public static void onLastOperator(Function, ? extends Publisher> onLastOperator) { + public static void onLastOperator(Function, ? extends @NonNull Publisher<@NonNull Object>> onLastOperator) { onLastOperator(onLastOperator.toString(), onLastOperator); } @@ -201,7 +202,7 @@ public static void onLastOperator(Function, ? extends * @see #resetOnLastOperator() * @see #onEachOperator(String, Function) */ - public static void onLastOperator(String key, Function, ? extends Publisher> onLastOperator) { + public static void onLastOperator(String key, Function, ? extends @NonNull Publisher<@NonNull Object>> onLastOperator) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(onLastOperator, "onLastOperator"); log.debug("Hooking onLastOperator: {}", key); @@ -249,7 +250,7 @@ public static void resetOnLastOperator() { * @param c the {@link Consumer} to apply to data (onNext) that is dropped * @see #onNextDroppedFail() */ - public static void onNextDropped(Consumer c) { + public static void onNextDropped(Consumer<@NonNull Object> c) { Objects.requireNonNull(c, "onNextDroppedHook"); log.debug("Hooking new default : onNextDropped"); @@ -318,7 +319,7 @@ public static void resetOnOperatorDebug() { * @see #resetOnOperatorError(String) * @see #resetOnOperatorError() */ - public static void onOperatorError(BiFunction onOperatorError) { + public static void onOperatorError(BiFunction onOperatorError) { onOperatorError(onOperatorError.toString(), onOperatorError); } @@ -345,7 +346,7 @@ public static void onOperatorError(BiFunction onOperatorError) { + public static void onOperatorError(String key, BiFunction onOperatorError) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(onOperatorError, "onOperatorError"); log.debug("Hooking onOperatorError: {}", key); @@ -408,7 +409,7 @@ public static void resetOnNextDropped() { @Nullable @SuppressWarnings("unchecked") - static Function createOrUpdateOpHook(Collection, ? extends Publisher>> hooks) { + static Function<@NonNull Publisher, @NonNull Publisher> createOrUpdateOpHook(Collection, ? extends @NonNull Publisher<@NonNull Object>>> hooks) { Function composite = null; for (Function, ? extends Publisher> function : hooks) { Function op = (Function) function; @@ -423,7 +424,7 @@ static Function createOrUpdateOpHook(Collection createOrUpdateOpErrorHook(Collection> hooks) { + static BiFunction createOrUpdateOpErrorHook(Collection<@NonNull BiFunction> hooks) { BiFunction composite = null; for (BiFunction function : hooks) { if (composite != null) { @@ -487,13 +488,13 @@ final static class OnOperatorDebug @SuppressWarnings("unchecked") - static OnOperatorDebug instance(){ + static OnOperatorDebug<@NonNull T> instance(){ return (OnOperatorDebug)INSTANCE; } @Override @SuppressWarnings("unchecked") - public Publisher apply(Publisher publisher) { + public Publisher<@NonNull T> apply(Publisher<@NonNull T> publisher) { if (publisher instanceof Callable) { if (publisher instanceof Mono) { return new MonoCallableOnAssembly<>((Mono) publisher); diff --git a/reactor-core/src/main/java/reactor/core/publisher/ImmutableSignal.java b/reactor-core/src/main/java/reactor/core/publisher/ImmutableSignal.java index 2008d02f49..195b1743d2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ImmutableSignal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ImmutableSignal.java @@ -20,7 +20,7 @@ import java.util.Objects; import org.reactivestreams.Subscription; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; /** * The common implementation of a {@link Signal} (serializable and immutable). diff --git a/reactor-core/src/main/java/reactor/core/publisher/InnerProducer.java b/reactor-core/src/main/java/reactor/core/publisher/InnerProducer.java index 9c04fc8385..ffadec4795 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/InnerProducer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/InnerProducer.java @@ -15,12 +15,12 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * diff --git a/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java index 25febc4a75..9310a6c23c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java @@ -18,13 +18,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.Disposable; import reactor.core.Exceptions; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * An unbounded Java Lambda adapter to {@link Subscriber}, targetted at {@link Mono}. diff --git a/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java index d069d4664f..a0db50d509 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java @@ -25,7 +25,7 @@ import reactor.core.Exceptions; import reactor.util.context.Context; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; /** * An unbounded Java Lambda adapter to {@link Subscriber} diff --git a/reactor-core/src/main/java/reactor/core/publisher/Mono.java b/reactor-core/src/main/java/reactor/core/publisher/Mono.java index 3e947154ce..b844374a1a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Mono.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Mono.java @@ -36,7 +36,6 @@ import java.util.function.Supplier; import java.util.logging.Level; import java.util.stream.LongStream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -57,6 +56,8 @@ import reactor.util.function.Tuple5; import reactor.util.function.Tuple6; import reactor.util.function.Tuples; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A Reactive Streams {@link Publisher} with basic rx operators that completes successfully by emitting an element, or @@ -167,7 +168,7 @@ public abstract class Mono implements Publisher { * @param The type of the value emitted * @return a {@link Mono} */ - public static Mono create(Consumer> callback) { + public static Mono<@NonNull T> create(Consumer<@NonNull MonoSink<@NonNull T>> callback) { return onAssembly(new MonoCreate<>(callback)); } @@ -184,7 +185,7 @@ public static Mono create(Consumer> callback) { * * @return a new {@link Mono} factory */ - public static Mono defer(Supplier> supplier) { + public static Mono<@NonNull T> defer(Supplier> supplier) { return onAssembly(new MonoDefer<>(supplier)); } @@ -201,7 +202,7 @@ public static Mono defer(Supplier> supplier) * * @return a new {@link Mono} */ - public static Mono delay(Duration duration) { + public static Mono<@NonNull Long> delay(Duration duration) { return delay(duration, Schedulers.parallel()); } @@ -218,7 +219,7 @@ public static Mono delay(Duration duration) { * * @return a new {@link Mono} */ - public static Mono delay(Duration duration, Scheduler timer) { + public static Mono<@NonNull Long> delay(Duration duration, Scheduler timer) { return onAssembly(new MonoDelay(duration.toMillis(), TimeUnit.MILLISECONDS, timer)); } @@ -232,7 +233,7 @@ public static Mono delay(Duration duration, Scheduler timer) { * * @return a completed {@link Mono} */ - public static Mono empty() { + public static Mono<@NonNull T> empty() { return MonoEmpty.instance(); } @@ -247,7 +248,7 @@ public static Mono empty() { * * @return a failed {@link Mono} */ - public static Mono error(Throwable error) { + public static Mono<@NonNull T> error(Throwable error) { return onAssembly(new MonoError<>(error)); } @@ -264,7 +265,7 @@ public static Mono error(Throwable error) { * @return a new {@link Mono} behaving like the fastest of its sources. */ @SafeVarargs - public static Mono first(Mono... monos) { + public static Mono<@NonNull T> first(Mono @NonNull ... monos) { return onAssembly(new MonoFirst<>(monos)); } @@ -279,7 +280,7 @@ public static Mono first(Mono... monos) { * * @return a {@link Mono}. */ - public static Mono first(Iterable> monos) { + public static Mono<@NonNull T> first(Iterable> monos) { return onAssembly(new MonoFirst<>(monos)); } @@ -294,7 +295,7 @@ public static Mono first(Iterable> monos) { * * @return the next item emitted as a {@link Mono} */ - public static Mono from(Publisher source) { + public static Mono<@NonNull T> from(Publisher source) { if (source instanceof Mono) { @SuppressWarnings("unchecked") Mono casted = (Mono) source; @@ -320,7 +321,7 @@ public static Mono from(Publisher source) { * * @return A {@link Mono}. */ - public static Mono fromCallable(Callable supplier) { + public static Mono<@NonNull T> fromCallable(Callable supplier) { return onAssembly(new MonoCallable<>(supplier)); } @@ -335,7 +336,7 @@ public static Mono fromCallable(Callable supplier) { * @param type of the expected value * @return A {@link Mono}. */ - public static Mono fromCompletionStage(CompletionStage completionStage) { + public static Mono<@NonNull T> fromCompletionStage(CompletionStage completionStage) { return onAssembly(new MonoCompletionStage<>(completionStage)); } @@ -351,7 +352,7 @@ public static Mono fromCompletionStage(CompletionStage compl * @param type of the value emitted by the publisher * @return a wrapped {@link Mono} */ - public static Mono fromDirect(Publisher source){ + public static Mono<@NonNull I> fromDirect(Publisher source){ if(source instanceof Mono){ @SuppressWarnings("unchecked") Mono m = (Mono)source; @@ -383,7 +384,7 @@ public static Mono fromDirect(Publisher source){ * @return A {@link Mono}. * @see #fromCompletionStage(CompletionStage) fromCompletionStage for a generalization */ - public static Mono fromFuture(CompletableFuture future) { + public static Mono<@NonNull T> fromFuture(CompletableFuture future) { return onAssembly(new MonoCompletionStage<>(future)); } @@ -399,7 +400,7 @@ public static Mono fromFuture(CompletableFuture future) { * @param The generic type of the upstream, which is preserved by this operator * @return A {@link Mono}. */ - public static Mono fromRunnable(Runnable runnable) { + public static Mono<@NonNull T> fromRunnable(Runnable runnable) { return onAssembly(new MonoRunnable<>(runnable)); } @@ -415,7 +416,7 @@ public static Mono fromRunnable(Runnable runnable) { * * @return A {@link Mono}. */ - public static Mono fromSupplier(Supplier supplier) { + public static Mono<@NonNull T> fromSupplier(Supplier supplier) { return onAssembly(new MonoSupplier<>(supplier)); } @@ -432,7 +433,7 @@ public static Mono fromSupplier(Supplier supplier) { * * @return a new completable {@link Mono}. */ - public static Mono ignoreElements(Publisher source) { + public static Mono<@NonNull T> ignoreElements(Publisher<@NonNull T> source) { return onAssembly(new MonoIgnorePublisher<>(source)); } @@ -448,7 +449,7 @@ public static Mono ignoreElements(Publisher source) { * * @return a {@link Mono}. */ - public static Mono just(T data) { + public static Mono<@NonNull T> just(T data) { return onAssembly(new MonoJust<>(data)); } @@ -464,7 +465,7 @@ public static Mono just(T data) { * * @return a {@link Mono}. */ - public static Mono justOrEmpty(@Nullable Optional data) { + public static Mono<@NonNull T> justOrEmpty(@Nullable Optional data) { return data != null && data.isPresent() ? just(data.get()) : empty(); } @@ -480,7 +481,7 @@ public static Mono justOrEmpty(@Nullable Optional data) { * * @return a {@link Mono}. */ - public static Mono justOrEmpty(@Nullable T data) { + public static Mono<@NonNull T> justOrEmpty(@Nullable T data) { return data != null ? just(data) : empty(); } @@ -495,7 +496,7 @@ public static Mono justOrEmpty(@Nullable T data) { * * @return a never completing {@link Mono} */ - public static Mono never() { + public static Mono<@NonNull T> never() { return MonoNever.instance(); } @@ -511,7 +512,7 @@ public static Mono never() { * the type of items emitted by each Publisher * @return a Mono that emits a Boolean value that indicates whether the two sequences are the same */ - public static Mono sequenceEqual(Publisher source1, Publisher source2) { + public static Mono<@NonNull Boolean> sequenceEqual(Publisher source1, Publisher source2) { return sequenceEqual(source1, source2, equalsBiPredicate(), Queues.SMALL_BUFFER_SIZE); } @@ -531,7 +532,7 @@ public static Mono sequenceEqual(Publisher source1, Pu * @return a Mono that emits a Boolean value that indicates whether the two Publisher two sequences * are the same according to the specified function */ - public static Mono sequenceEqual(Publisher source1, Publisher source2, + public static Mono<@NonNull Boolean> sequenceEqual(Publisher source1, Publisher source2, BiPredicate isEqual) { return sequenceEqual(source1, source2, isEqual, Queues.SMALL_BUFFER_SIZE); } @@ -554,9 +555,9 @@ public static Mono sequenceEqual(Publisher source1, Pu * @return a Mono that emits a Boolean value that indicates whether the two Publisher two sequences * are the same according to the specified function */ - public static Mono sequenceEqual(Publisher source1, - Publisher source2, - BiPredicate isEqual, int prefetch) { + public static Mono<@NonNull Boolean> sequenceEqual(Publisher source1, + Publisher source2, + BiPredicate isEqual, int prefetch) { return onAssembly(new MonoSequenceEqual<>(source1, source2, isEqual, prefetch)); } @@ -572,7 +573,7 @@ public static Mono sequenceEqual(Publisher source1, * @return a new {@link Mono} emitting current context * @see #subscribe(CoreSubscriber) */ - public static Mono subscriberContext() { + public static Mono<@NonNull Context> subscriberContext() { return onAssembly(MonoCurrentContext.INSTANCE); } @@ -596,9 +597,9 @@ public static Mono subscriberContext() { * * @return new {@link Mono} */ - public static Mono using(Callable resourceSupplier, - Function> sourceSupplier, - Consumer resourceCleanup, + public static Mono<@NonNull T> using(Callable resourceSupplier, + Function> sourceSupplier, + Consumer resourceCleanup, boolean eager) { return onAssembly(new MonoUsing<>(resourceSupplier, sourceSupplier, resourceCleanup, eager)); @@ -623,9 +624,9 @@ public static Mono using(Callable resourceSupplier, * * @return new {@link Mono} */ - public static Mono using(Callable resourceSupplier, - Function> sourceSupplier, - Consumer resourceCleanup) { + public static Mono<@NonNull T> using(Callable resourceSupplier, + Function> sourceSupplier, + Consumer resourceCleanup) { return using(resourceSupplier, sourceSupplier, resourceCleanup, true); } @@ -640,7 +641,7 @@ public static Mono using(Callable resourceSupplier, * * @return a {@link Mono}. */ - public static Mono when(Publisher... sources) { + public static Mono when(Publisher<@NonNull ?> @NonNull ... sources) { if (sources.length == 0) { return empty(); } @@ -665,7 +666,7 @@ public static Mono when(Publisher... sources) { * * @return a {@link Mono}. */ - public static Mono when(final Iterable> sources) { + public static Mono when(final @NonNull Iterable> sources) { return onAssembly(new MonoWhen(false, sources)); } @@ -684,7 +685,7 @@ public static Mono when(final Iterable> sources) { * * @return a {@link Mono}. */ - public static Mono whenDelayError(final Iterable> sources) { + public static Mono whenDelayError(final Iterable> sources) { return onAssembly(new MonoWhen(true, sources)); } @@ -700,7 +701,7 @@ public static Mono whenDelayError(final Iterable> s * * @return a {@link Mono}. */ - public static Mono whenDelayError(Publisher... sources) { + public static Mono whenDelayError(Publisher<@NonNull ?> @NonNull ... sources) { if (sources.length == 0) { return empty(); } @@ -726,7 +727,7 @@ public static Mono whenDelayError(Publisher... sources) { * * @return a {@link Mono}. */ - public static Mono> zip(Mono p1, Mono p2) { + public static Mono<@NonNull Tuple2<@NonNull T1, @NonNull T2>> zip(Mono p1, Mono p2) { return zip(p1, p2, Flux.tuple2Function()); } @@ -749,8 +750,8 @@ public static Mono> zip(Mono p1, Mono Mono zip(Mono p1, Mono p2, BiFunction combinator) { + public static Mono zip(Mono p1, Mono p2, BiFunction combinator) { return onAssembly(new MonoZip(false, p1, p2, combinator)); } @@ -773,7 +774,7 @@ public static Mono zip(Mono p1, Mono Mono> zip(Mono p1, Mono p2, Mono p3) { + public static Mono<@NonNull Tuple3<@NonNull T1, @NonNull T2, @NonNull T3>> zip(Mono p1, Mono p2, Mono p3) { return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3)); } @@ -798,7 +799,7 @@ public static Mono> zip(Mono p1, M * @return a {@link Mono}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Mono> zip(Mono p1, + public static Mono<@NonNull Tuple4<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4>> zip(Mono p1, Mono p2, Mono p3, Mono p4) { @@ -828,11 +829,11 @@ public static Mono> zip(Mono Mono> zip(Mono p1, - Mono p2, - Mono p3, - Mono p4, - Mono p5) { + public static Mono<@NonNull Tuple5<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4, @NonNull T5>> zip(Mono p1, + Mono p2, + Mono p3, + Mono p4, + Mono p5) { return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5)); } @@ -861,12 +862,12 @@ public static Mono> zip(Mono Mono> zip(Mono p1, - Mono p2, - Mono p3, - Mono p4, - Mono p5, - Mono p6) { + public static Mono<@NonNull Tuple6<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4, @NonNull T5, @NonNull T6>> zip(Mono p1, + Mono p2, + Mono p3, + Mono p4, + Mono p5, + Mono p6) { return onAssembly(new MonoZip(false, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5, p6)); } @@ -886,7 +887,7 @@ public static Mono> zip( * * @return a {@link Mono}. */ - public static Mono zip(final Iterable> monos, Function combinator) { + public static Mono<@NonNull R> zip(final Iterable> monos, Function combinator) { return onAssembly(new MonoZip<>(false, combinator, monos)); } @@ -905,7 +906,7 @@ public static Mono zip(final Iterable> monos, Function< * * @return a {@link Mono}. */ - public static Mono zip(Function combinator, Mono... monos) { + public static Mono<@NonNull R> zip(Function combinator, Mono<@NonNull ?> @NonNull ... monos) { if (monos.length == 0) { return empty(); } @@ -931,7 +932,7 @@ public static Mono zip(Function combinator * @return a {@link Mono}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Mono> zipDelayError(Mono p1, Mono p2) { + public static Mono<@NonNull Tuple2<@NonNull T1, @NonNull T2>> zipDelayError(Mono p1, Mono p2) { return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2)); } @@ -953,7 +954,7 @@ public static Mono> zipDelayError(Mono p1, * @return a {@link Mono}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Mono> zipDelayError(Mono p1, Mono p2, Mono p3) { + public static Mono<@NonNull Tuple3<@NonNull T1, @NonNull T2, @NonNull T3>> zipDelayError(Mono p1, Mono p2, Mono p3) { return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3)); } @@ -977,10 +978,10 @@ public static Mono> zipDelayError(Mono Mono> zipDelayError(Mono p1, - Mono p2, - Mono p3, - Mono p4) { + public static Mono<@NonNull Tuple4<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4>> zipDelayError(Mono p1, + Mono p2, + Mono p3, + Mono p4) { return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4)); } @@ -1005,11 +1006,11 @@ public static Mono> zipDelayError(Mono Mono> zipDelayError(Mono p1, - Mono p2, - Mono p3, - Mono p4, - Mono p5) { + public static Mono<@NonNull Tuple5<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4, @NonNull T5>> zipDelayError(Mono p1, + Mono p2, + Mono p3, + Mono p4, + Mono p5) { return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5)); } @@ -1037,12 +1038,12 @@ public static Mono> zipDelayErro * @return a {@link Mono}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Mono> zipDelayError(Mono p1, - Mono p2, - Mono p3, - Mono p4, - Mono p5, - Mono p6) { + public static Mono<@NonNull Tuple6<@NonNull T1, @NonNull T2, @NonNull T3, @NonNull T4, @NonNull T5, @NonNull T6>> zipDelayError(Mono p1, + Mono p2, + Mono p3, + Mono p4, + Mono p5, + Mono p6) { return onAssembly(new MonoZip(true, a -> Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5, p6)); } @@ -1063,7 +1064,7 @@ public static Mono> zipD * * @return a {@link Mono}. */ - public static Mono zipDelayError(final Iterable> monos, Function combinator) { + public static Mono<@NonNull R> zipDelayError(final Iterable> monos, Function combinator) { return onAssembly(new MonoZip<>(true, combinator, monos)); } @@ -1083,8 +1084,8 @@ public static Mono zipDelayError(final Iterable> monos, * * @return a combined {@link Mono}. */ - public static Mono zipDelayError(Function - combinator, Mono... monos) { + public static Mono<@NonNull R> zipDelayError(Function + combinator, Mono @NonNull ... monos) { if (monos.length == 0) { return empty(); } @@ -1112,7 +1113,7 @@ public static Mono zipDelayError(Function * @return the {@link Mono} transformed to an instance of P * @see #compose for a bounded conversion to {@link Publisher} */ - public final

P as(Function, P> transformer) { + public final

P as(Function, @NonNull P> transformer) { return transformer.apply(this); } @@ -1128,7 +1129,7 @@ public final

P as(Function, P> transformer) { * @return a new combined Mono * @see #when */ - public final Mono and(Publisher other) { + public final Mono and(Publisher<@NonNull ?> other) { if (this instanceof MonoWhen) { @SuppressWarnings("unchecked") MonoWhen o = (MonoWhen) this; Mono result = o.whenAdditionalSource(other); @@ -1196,7 +1197,7 @@ public T block(Duration timeout) { * * @return a casted {@link Mono} */ - public final Mono cast(Class clazz) { + public final Mono<@NonNull E> cast(Class clazz) { Objects.requireNonNull(clazz, "clazz"); return map(clazz::cast); } @@ -1210,11 +1211,11 @@ public final Mono cast(Class clazz) { * * @return a replaying {@link Mono} */ - public final Mono cache() { + public final Mono<@NonNull T> cache() { return onAssembly(new MonoProcessor<>(this)); } - public final Mono cache(Duration ttl) { + public final Mono<@NonNull T> cache(Duration ttl) { return onAssembly(new MonoCacheTime<>(this, ttl, Schedulers.parallel())); } @@ -1227,7 +1228,7 @@ public final Mono cache(Duration ttl) { * * @return a scheduled cancel {@link Mono} */ - public final Mono cancelOn(Scheduler scheduler) { + public final Mono<@NonNull T> cancelOn(Scheduler scheduler) { return onAssembly(new MonoCancelOn<>(this, scheduler)); } @@ -1241,7 +1242,7 @@ public final Mono cancelOn(Scheduler scheduler) { * * @return the assembly tracing {@link Mono} */ - public final Mono checkpoint() { + public final Mono<@NonNull T> checkpoint() { return checkpoint(null, true); } @@ -1261,7 +1262,7 @@ public final Mono checkpoint() { * @param description a unique enough description to include in the light assembly traceback. * @return the assembly marked {@link Mono} */ - public final Mono checkpoint(String description) { + public final Mono<@NonNull T> checkpoint(String description) { return checkpoint(Objects.requireNonNull(description), false); } @@ -1291,7 +1292,7 @@ public final Mono checkpoint(String description) { * to use a stack trace. * @return the assembly marked {@link Mono}. */ - public final Mono checkpoint(@Nullable String description, boolean forceStackTrace) { + public final Mono<@NonNull T> checkpoint(@Nullable String description, boolean forceStackTrace) { return new MonoOnAssembly<>(this, description, !forceStackTrace); } @@ -1312,7 +1313,7 @@ public final Mono checkpoint(@Nullable String description, boolean forceStack * @see #as as() for a loose conversion to an arbitrary type * @see #transform(Function) */ - public final Mono compose(Function, ? extends Publisher> transformer) { + public final Mono<@NonNull V> compose(Function, ? extends @NonNull Publisher<@NonNull V>> transformer) { return defer(() -> from(transformer.apply(this))); } @@ -1326,7 +1327,7 @@ public final Mono compose(Function, ? extends Publisher concatWith(Publisher other) { + public final Flux<@NonNull T> concatWith(Publisher other) { return Flux.concat(this, other); } @@ -1342,7 +1343,7 @@ public final Flux concatWith(Publisher other) { * * @see Flux#defaultIfEmpty(Object) */ - public final Mono defaultIfEmpty(T defaultV) { + public final Mono<@NonNull T> defaultIfEmpty(T defaultV) { if (this instanceof Fuseable.ScalarCallable) { try { T v = block(); @@ -1373,7 +1374,7 @@ public final Mono defaultIfEmpty(T defaultV) { * @param delay duration by which to delay the {@link Subscriber#onNext} signal * @return a delayed {@link Mono} */ - public final Mono delayElement(Duration delay) { + public final Mono<@NonNull T> delayElement(Duration delay) { return delayElement(delay, Schedulers.parallel()); } @@ -1393,7 +1394,7 @@ public final Mono delayElement(Duration delay) { * @param timer a time-capable {@link Scheduler} instance to delay the value signal on * @return a delayed {@link Mono} */ - public final Mono delayElement(Duration delay, Scheduler timer) { + public final Mono<@NonNull T> delayElement(Duration delay, Scheduler timer) { return onAssembly(new MonoDelayElement<>(this, delay.toMillis(), TimeUnit.MILLISECONDS, timer)); } @@ -1417,7 +1418,7 @@ public final Mono delayElement(Duration delay, Scheduler timer) { * * @return this Mono, but delayed until the derived publisher terminates. */ - public final Mono delayUntil(Function> triggerProvider) { + public final Mono<@NonNull T> delayUntil(Function> triggerProvider) { Objects.requireNonNull(triggerProvider, "triggerProvider required"); if (this instanceof MonoDelayUntil) { return ((MonoDelayUntil) this).copyWithNewTriggerGenerator(false,triggerProvider); @@ -1437,7 +1438,7 @@ public final Mono delayUntil(Function> trig * @return a delayed {@link Mono} * */ - public final Mono delaySubscription(Duration delay) { + public final Mono<@NonNull T> delaySubscription(Duration delay) { return delaySubscription(delay, Schedulers.parallel()); } @@ -1454,7 +1455,7 @@ public final Mono delaySubscription(Duration delay) { * @return a delayed {@link Mono} * */ - public final Mono delaySubscription(Duration delay, Scheduler timer) { + public final Mono<@NonNull T> delaySubscription(Duration delay, Scheduler timer) { return delaySubscription(Mono.delay(delay, timer)); } @@ -1472,7 +1473,7 @@ public final Mono delaySubscription(Duration delay, Scheduler timer) { * @return a delayed {@link Mono} * */ - public final Mono delaySubscription(Publisher subscriptionDelay) { + public final Mono<@NonNull T> delaySubscription(Publisher<@NonNull U> subscriptionDelay) { return onAssembly(new MonoDelaySubscription<>(this, subscriptionDelay)); } @@ -1490,7 +1491,7 @@ public final Mono delaySubscription(Publisher subscriptionDelay) { * @return a dematerialized {@link Mono} * @see #materialize() */ - public final Mono dematerialize() { + public final Mono<@NonNull X> dematerialize() { @SuppressWarnings("unchecked") Mono> thiz = (Mono>) this; return onAssembly(new MonoDematerialize<>(thiz)); @@ -1512,7 +1513,7 @@ public final Mono dematerialize() { * * @return a new {@link Mono} */ - public final Mono doAfterSuccessOrError(BiConsumer afterSuccessOrError) { + public final Mono<@NonNull T> doAfterSuccessOrError(BiConsumer afterSuccessOrError) { return onAssembly(new MonoPeekTerminal<>(this, null, null, afterSuccessOrError)); } @@ -1547,7 +1548,7 @@ public final Mono doAfterTerminate(Runnable afterTerminate) { * or cancel) * @return an observed {@link Mono} */ - public final Mono doFinally(Consumer onFinally) { + public final Mono<@NonNull T> doFinally(Consumer<@NonNull SignalType> onFinally) { Objects.requireNonNull(onFinally, "onFinally"); if (this instanceof Fuseable) { return onAssembly(new MonoDoFinallyFuseable<>(this, onFinally)); @@ -1566,7 +1567,7 @@ public final Mono doFinally(Consumer onFinally) { * * @return a new {@link Mono} */ - public final Mono doOnCancel(Runnable onCancel) { + public final Mono<@NonNull T> doOnCancel(Runnable onCancel) { Objects.requireNonNull(onCancel, "onCancel"); return doOnSignal(this, null, null, null, null, null, onCancel); } @@ -1582,7 +1583,7 @@ public final Mono doOnCancel(Runnable onCancel) { * * @return a new {@link Mono} */ - public final Mono doOnNext(Consumer onNext) { + public final Mono<@NonNull T> doOnNext(Consumer onNext) { Objects.requireNonNull(onNext, "onNext"); return doOnSignal(this, null, onNext, null, null, null, null); } @@ -1604,7 +1605,7 @@ public final Mono doOnNext(Consumer onNext) { * * @return a new {@link Mono} */ - public final Mono doOnSuccess(Consumer onSuccess) { + public final Mono<@NonNull T> doOnSuccess(Consumer onSuccess) { Objects.requireNonNull(onSuccess, "onSuccess"); return onAssembly(new MonoPeekTerminal<>(this, onSuccess, null, null)); } @@ -1624,7 +1625,7 @@ public final Mono doOnSuccess(Consumer onSuccess) { * @see #materialize() * @see Signal */ - public final Mono doOnEach(Consumer> signalConsumer) { + public final Mono<@NonNull T> doOnEach(Consumer> signalConsumer) { Objects.requireNonNull(signalConsumer, "signalConsumer"); return doOnSignal(this, null, @@ -1643,7 +1644,7 @@ public final Mono doOnEach(Consumer> signalConsumer) { * * @return a new {@link Mono} */ - public final Mono doOnError(Consumer onError) { + public final Mono<@NonNull T> doOnError(Consumer onError) { Objects.requireNonNull(onError, "onError"); return doOnSignal(this, null, null, onError, null, null, null); } @@ -1661,8 +1662,8 @@ public final Mono doOnError(Consumer onError) { * @return an observed {@link Mono} * */ - public final Mono doOnError(Class exceptionType, - final Consumer onError) { + public final Mono<@NonNull T> doOnError(Class exceptionType, + final Consumer onError) { Objects.requireNonNull(exceptionType, "type"); @SuppressWarnings("unchecked") Consumer handler = (Consumer)onError; @@ -1680,8 +1681,8 @@ public final Mono doOnError(Class exceptionType, * @return an observed {@link Mono} * */ - public final Mono doOnError(Predicate predicate, - final Consumer onError) { + public final Mono<@NonNull T> doOnError(Predicate predicate, + final Consumer onError) { Objects.requireNonNull(predicate, "predicate"); return doOnError(t -> { if (predicate.test(t)) { @@ -1702,7 +1703,7 @@ public final Mono doOnError(Predicate predicate, * * @return an observed {@link Mono} */ - public final Mono doOnRequest(final LongConsumer consumer) { + public final Mono<@NonNull T> doOnRequest(final LongConsumer consumer) { Objects.requireNonNull(consumer, "consumer"); return doOnSignal(this, null, null, null, null, consumer, null); } @@ -1717,7 +1718,7 @@ public final Mono doOnRequest(final LongConsumer consumer) { * * @return a new {@link Mono} */ - public final Mono doOnSubscribe(Consumer onSubscribe) { + public final Mono<@NonNull T> doOnSubscribe(Consumer onSubscribe) { Objects.requireNonNull(onSubscribe, "onSubscribe"); return doOnSignal(this, onSubscribe, null, null, null, null, null); } @@ -1738,7 +1739,7 @@ public final Mono doOnSubscribe(Consumer onSubscribe) { * * @return a new {@link Mono} */ - public final Mono doOnSuccessOrError(BiConsumer onSuccessOrError) { + public final Mono doOnSuccessOrError(BiConsumer onSuccessOrError) { Objects.requireNonNull(onSuccessOrError, "onSuccessOrError"); return onAssembly(new MonoPeekTerminal<>(this, null, onSuccessOrError, null)); } @@ -1774,7 +1775,7 @@ public final Mono doOnTerminate(Runnable onTerminate) { * * @return a new {@link Mono} that emits a tuple of time elapsed in milliseconds and matching data */ - public final Mono> elapsed() { + public final Mono<@NonNull Tuple2<@NonNull Long, @NonNull T>> elapsed() { return elapsed(Schedulers.parallel()); } @@ -1789,7 +1790,7 @@ public final Mono> elapsed() { * @param scheduler a {@link Scheduler} instance to read time from * @return a new {@link Mono} that emits a tuple of time elapsed in milliseconds and matching data */ - public final Mono> elapsed(Scheduler scheduler) { + public final Mono<@NonNull Tuple2<@NonNull Long, @NonNull T>> elapsed(Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler"); return onAssembly(new MonoElapsed<>(this, scheduler)); } @@ -1959,7 +1960,7 @@ public final Flux expand(Function * * @return a filtered {@link Mono} */ - public final Mono filter(final Predicate tester) { + public final Mono<@NonNull T> filter(final Predicate tester) { if (this instanceof Fuseable) { return onAssembly(new MonoFilterFuseable<>(this, tester)); } @@ -1979,7 +1980,7 @@ public final Mono filter(final Predicate tester) { * to filter the Mono with * @return a filtered {@link Mono} */ - public final Mono filterWhen(Function> asyncPredicate) { + public final Mono<@NonNull T> filterWhen(Function> asyncPredicate) { return onAssembly(new MonoFilterWhen<>(this, asyncPredicate)); } @@ -1995,7 +1996,7 @@ public final Mono filterWhen(Function * * @return a new {@link Mono} with an asynchronously mapped value. */ - public final Mono flatMap(Function> + public final Mono<@NonNull R> flatMap(Function> transformer) { return onAssembly(new MonoFlatMap<>(this, transformer)); } @@ -2013,7 +2014,7 @@ public final Mono flatMap(Function * * @return a new {@link Flux} as the sequence is not guaranteed to be single at most */ - public final Flux flatMapMany(Function> mapper) { + public final Flux<@NonNull R> flatMapMany(Function> mapper) { return Flux.onAssembly(new MonoFlatMapMany<>(this, mapper)); } @@ -2033,7 +2034,7 @@ public final Flux flatMapMany(Function Flux flatMapMany(Function> mapperOnNext, + public final Flux<@NonNull R> flatMapMany(Function> mapperOnNext, Function> mapperOnError, Supplier> mapperOnComplete) { return flux().flatMap(mapperOnNext, mapperOnError, mapperOnComplete); @@ -2053,7 +2054,7 @@ public final Flux flatMapMany(Function Flux flatMapIterable(Function> mapper) { + public final Flux<@NonNull R> flatMapIterable(Function> mapper) { return Flux.onAssembly(new MonoFlattenIterable<>(this, mapper, Integer .MAX_VALUE, Queues.one())); } @@ -2063,7 +2064,7 @@ public final Flux flatMapIterable(Function flux() { + public final Flux<@NonNull T> flux() { if (this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { T v; @@ -2093,7 +2094,7 @@ public final Flux flux() { * @return a new {@link Mono} with true if a value is emitted and false * otherwise */ - public final Mono hasElement() { + public final Mono<@NonNull Boolean> hasElement() { return onAssembly(new MonoHasElement<>(this)); } @@ -2108,7 +2109,7 @@ public final Mono hasElement() { * * @return a transformed {@link Mono} */ - public final Mono handle(BiConsumer> handler) { + public final Mono<@NonNull R> handle(BiConsumer> handler) { if (this instanceof Fuseable) { return onAssembly(new MonoHandleFuseable<>(this, handler)); } @@ -2123,7 +2124,7 @@ public final Mono handle(BiConsumer> handle * * @return a new {@link Mono} preventing {@link Publisher} / {@link Subscription} based Reactor optimizations */ - public final Mono hide() { + public final Mono<@NonNull T> hide() { return onAssembly(new MonoHide<>(this)); } @@ -2136,7 +2137,7 @@ public final Mono hide() { * * @return a new empty {@link Mono} representing the completion of this {@link Mono}. */ - public final Mono ignoreElement() { + public final Mono<@NonNull T> ignoreElement() { return onAssembly(new MonoIgnoreElement<>(this)); } @@ -2155,7 +2156,7 @@ public final Mono ignoreElement() { * * @see Flux#log() */ - public final Mono log() { + public final Mono<@NonNull T> log() { return log(null, Level.INFO); } @@ -2197,7 +2198,7 @@ public final Mono log(@Nullable String category) { * @return a new {@link Mono} * */ - public final Mono log(@Nullable String category, Level level, SignalType... options) { + public final Mono<@NonNull T> log(@Nullable String category, Level level, SignalType @NonNull ... options) { return log(category, level, false, options); } @@ -2225,10 +2226,10 @@ public final Mono log(@Nullable String category, Level level, SignalType... o * * @return a new unaltered {@link Mono} */ - public final Mono log(@Nullable String category, + public final Mono<@NonNull T> log(@Nullable String category, Level level, boolean showOperatorLine, - SignalType... options) { + SignalType @NonNull ... options) { SignalLogger log = new SignalLogger<>(this, category, level, showOperatorLine, options); @@ -2249,7 +2250,7 @@ public final Mono log(@Nullable String category, * * @return a new {@link Mono} */ - public final Mono map(Function mapper) { + public final Mono<@NonNull R> map(Function mapper) { if (this instanceof Fuseable) { return onAssembly(new MonoMapFuseable<>(this, mapper)); } @@ -2268,7 +2269,7 @@ public final Mono map(Function mapper) { * @return a {@link Mono} of materialized {@link Signal} * @see #dematerialize() */ - public final Mono> materialize() { + public final Mono<@NonNull Signal<@Nullable T>> materialize() { return onAssembly(new MonoMaterialize<>(this)); } @@ -2283,7 +2284,7 @@ public final Mono> materialize() { * * @return a new {@link Flux} as the sequence is not guaranteed to be at most 1 */ - public final Flux mergeWith(Publisher other) { + public final Flux<@NonNull T> mergeWith(Publisher other) { return Flux.merge(this, other); } @@ -2294,7 +2295,7 @@ public final Flux mergeWith(Publisher other) { * @param name a name for the sequence * @return the same sequence, but bearing a name */ - public final Mono name(String name) { + public final Mono<@NonNull T> name(String name) { return MonoName.createOrAppend(this, name); } @@ -2309,7 +2310,7 @@ public final Mono name(String name) { * @return a new {@link Mono} * @see #first */ - public final Mono or(Mono other) { + public final Mono<@NonNull T> or(Mono other) { if (this instanceof MonoFirst) { MonoFirst a = (MonoFirst) this; Mono result = a.orAdditionalSource(other); @@ -2332,7 +2333,7 @@ public final Mono or(Mono other) { * * @return a new {@link Mono} filtered on the requested type */ - public final Mono ofType(final Class clazz) { + public final Mono<@NonNull U> ofType(final Class clazz) { Objects.requireNonNull(clazz, "clazz"); return filter(o -> clazz.isAssignableFrom(o.getClass())).cast(clazz); } @@ -2349,8 +2350,8 @@ public final Mono ofType(final Class clazz) { * * @return a {@link Mono} that transforms some source errors to other errors */ - public final Mono onErrorMap(Predicate predicate, - Function mapper) { + public final Mono<@NonNull T> onErrorMap(Predicate predicate, + Function mapper) { return onErrorResume(predicate, e -> Mono.error(mapper.apply(e))); } @@ -2364,7 +2365,7 @@ public final Mono onErrorMap(Predicate predicate, * * @return a {@link Mono} that transforms source errors to other errors */ - public final Mono onErrorMap(Function mapper) { + public final Mono<@NonNull T> onErrorMap(Function mapper) { return onErrorResume(e -> Mono.error(mapper.apply(e))); } @@ -2380,8 +2381,8 @@ public final Mono onErrorMap(Function * * @return a {@link Mono} that transforms some source errors to other errors */ - public final Mono onErrorMap(Class type, - Function mapper) { + public final Mono<@NonNull T> onErrorMap(Class type, + Function mapper) { @SuppressWarnings("unchecked") Function handler = (Function)mapper; return onErrorMap(type::isInstance, handler); @@ -2400,8 +2401,8 @@ public final Mono onErrorMap(Class type, * * @see Flux#onErrorResume */ - public final Mono onErrorResume(Function> fallback) { + public final Mono<@NonNull T> onErrorResume(Function> fallback) { return onAssembly(new MonoOnErrorResume<>(this, fallback)); } @@ -2419,8 +2420,8 @@ public final Mono onErrorResume(Function Mono onErrorResume(Class type, - Function> fallback) { + public final Mono<@NonNull T> onErrorResume(Class type, + Function> fallback) { Objects.requireNonNull(type, "type"); @SuppressWarnings("unchecked") Function> handler = (Function Mono onErrorResume(Class type, * @return a {@link Mono} falling back upon source onError * @see Flux#onErrorResume */ - public final Mono onErrorResume(Predicate predicate, - Function> fallback) { + public final Mono<@NonNull T> onErrorResume(Predicate predicate, + Function> fallback) { Objects.requireNonNull(predicate, "predicate"); return onErrorResume(e -> predicate.test(e) ? fallback.apply(e) : error(e)); } @@ -2456,7 +2457,7 @@ public final Mono onErrorResume(Predicate predicate, * * @return a new falling back {@link Mono} */ - public final Mono onErrorReturn(final T fallback) { + public final Mono<@NonNull T> onErrorReturn(final T fallback) { return onErrorResume(throwable -> just(fallback)); } @@ -2471,7 +2472,7 @@ public final Mono onErrorReturn(final T fallback) { * * @return a new falling back {@link Mono} */ - public final Mono onErrorReturn(Class type, T fallbackValue) { + public final Mono<@NonNull T> onErrorReturn(Class type, T fallbackValue) { return onErrorResume(type, throwable -> just(fallbackValue)); } @@ -2485,7 +2486,7 @@ public final Mono onErrorReturn(Class type, T fallba * * @return a new {@link Mono} */ - public final Mono onErrorReturn(Predicate predicate, T fallbackValue) { + public final Mono<@NonNull T> onErrorReturn(Predicate predicate, T fallbackValue) { return onErrorResume(predicate, throwable -> just(fallbackValue)); } @@ -2497,7 +2498,7 @@ public final Mono onErrorReturn(Predicate predicate, T fal * * @return a detachable {@link Mono} */ - public final Mono onTerminateDetach() { + public final Mono<@NonNull T> onTerminateDetach() { return new MonoDetach<>(this); } @@ -2511,8 +2512,8 @@ public final Mono onTerminateDetach() { * * @return a new {@link Mono} */ - public final Mono publish(Function, ? extends Mono> transform) { + public final Mono<@NonNull R> publish(Function, ? extends @NonNull Mono> transform) { return onAssembly(new MonoPublishMulticast<>(this, transform)); } @@ -2535,7 +2536,7 @@ public final Mono publish(Function, ? extends Mono publishOn(Scheduler scheduler) { + public final Mono<@NonNull T> publishOn(Scheduler scheduler) { if(this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { try { @@ -2562,7 +2563,7 @@ public final Mono publishOn(Scheduler scheduler) { * * @return an indefinitely repeated {@link Flux} on onComplete */ - public final Flux repeat() { + public final Flux<@NonNull T> repeat() { return repeat(Flux.ALWAYS_BOOLEAN_SUPPLIER); } @@ -2577,7 +2578,7 @@ public final Flux repeat() { * @return a {@link Flux} that repeats on onComplete while the predicate matches * */ - public final Flux repeat(BooleanSupplier predicate) { + public final Flux<@NonNull T> repeat(BooleanSupplier predicate) { return Flux.onAssembly(new MonoRepeatPredicate<>(this, predicate)); } @@ -2591,7 +2592,7 @@ public final Flux repeat(BooleanSupplier predicate) { * * @return a {@link Flux} that repeats on onComplete, up to the specified number of repetitions */ - public final Flux repeat(long numRepeat) { + public final Flux<@NonNull T> repeat(long numRepeat) { if(numRepeat == 0){ return Flux.empty(); } @@ -2611,7 +2612,7 @@ public final Flux repeat(long numRepeat) { * @return a {@link Flux} that repeats on onComplete while the predicate matches, * up to the specified number of repetitions */ - public final Flux repeat(long numRepeat, BooleanSupplier predicate) { + public final Flux<@NonNull T> repeat(long numRepeat, BooleanSupplier predicate) { return Flux.defer(() -> repeat(Flux.countingBooleanSupplier(predicate, numRepeat))); } @@ -2632,7 +2633,7 @@ public final Flux repeat(long numRepeat, BooleanSupplier predicate) { * @return a {@link Flux} that repeats on onComplete when the companion {@link Publisher} produces an * onNext signal */ - public final Flux repeatWhen(Function, ? extends Publisher> repeatFactory) { + public final Flux<@NonNull T> repeatWhen(Function<@NonNull Flux<@NonNull Long>, ? extends @NonNull Publisher<@NonNull ?>> repeatFactory) { return Flux.onAssembly(new MonoRepeatWhen<>(this, repeatFactory)); } @@ -2652,7 +2653,7 @@ public final Flux repeatWhen(Function, ? extends Publisher> rep * as long as the companion {@link Publisher} produces an onNext signal * */ - public final Mono repeatWhenEmpty(Function, ? extends Publisher> repeatFactory) { + public final Mono<@NonNull T> repeatWhenEmpty(Function<@NonNull Flux<@NonNull Long>, ? extends @NonNull Publisher<@NonNull ?>> repeatFactory) { return repeatWhenEmpty(Integer.MAX_VALUE, repeatFactory); } @@ -2675,7 +2676,7 @@ public final Mono repeatWhenEmpty(Function, ? extends Publisher * @return a {@link Mono} that resubscribes to this {@link Mono} if the previous subscription was empty, * as long as the companion {@link Publisher} produces an onNext signal and the maximum number of repeats isn't exceeded. */ - public final Mono repeatWhenEmpty(int maxRepeat, Function, ? extends Publisher> repeatFactory) { + public final Mono<@NonNull T> repeatWhenEmpty(int maxRepeat, Function<@NonNull Flux<@NonNull Long>, ? extends @NonNull Publisher<@NonNull ?>> repeatFactory) { return Mono.defer(() -> { Flux iterations; @@ -2703,7 +2704,7 @@ public final Mono repeatWhenEmpty(int maxRepeat, Function, ? exten * * @return a {@link Mono} that retries on onError */ - public final Mono retry() { + public final Mono<@NonNull T> retry() { return retry(Long.MAX_VALUE); } @@ -2719,7 +2720,7 @@ public final Mono retry() { * * @return a {@link Mono} that retries on onError up to the specified number of retry attempts. */ - public final Mono retry(long numRetries) { + public final Mono<@NonNull T> retry(long numRetries) { return onAssembly(new MonoRetry<>(this, numRetries)); } @@ -2734,7 +2735,7 @@ public final Mono retry(long numRetries) { * * @return a {@link Mono} that retries on onError if the predicates matches. */ - public final Mono retry(Predicate retryMatcher) { + public final Mono<@NonNull T> retry(Predicate retryMatcher) { return onAssembly(new MonoRetryPredicate<>(this, retryMatcher)); } @@ -2752,7 +2753,7 @@ public final Mono retry(Predicate retryMatcher) { * attempts, only if the predicate matches. * */ - public final Mono retry(long numRetries, Predicate retryMatcher) { + public final Mono<@NonNull T> retry(long numRetries, Predicate retryMatcher) { return defer(() -> retry(Flux.countingPredicate(retryMatcher, numRetries))); } @@ -2772,7 +2773,7 @@ public final Mono retry(long numRetries, Predicate retryMa * @return a {@link Mono} that retries on onError when the companion {@link Publisher} produces an * onNext signal */ - public final Mono retryWhen(Function, ? extends Publisher> whenFactory) { + public final Mono<@NonNull T> retryWhen(Function<@NonNull Flux<@NonNull Throwable>, ? extends @NonNull Publisher<@NonNull ?>> whenFactory) { return onAssembly(new MonoRetryWhen<>(this, whenFactory)); } @@ -2816,7 +2817,7 @@ public final Disposable subscribe() { * * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ - public final Disposable subscribe(Consumer consumer) { + public final Disposable subscribe(Consumer consumer) { Objects.requireNonNull(consumer, "consumer"); return subscribe(consumer, null, null); } @@ -2841,7 +2842,7 @@ public final Disposable subscribe(Consumer consumer) { * * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ - public final Disposable subscribe(@Nullable Consumer consumer, Consumer errorConsumer) { + public final Disposable subscribe(@Nullable Consumer consumer, Consumer errorConsumer) { Objects.requireNonNull(errorConsumer, "errorConsumer"); return subscribe(consumer, errorConsumer, null); } @@ -2868,8 +2869,8 @@ public final Disposable subscribe(@Nullable Consumer consumer, Consum * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ public final Disposable subscribe( - @Nullable Consumer consumer, - @Nullable Consumer errorConsumer, + @Nullable Consumer consumer, + @Nullable Consumer errorConsumer, @Nullable Runnable completeConsumer) { return subscribe(consumer, errorConsumer, completeConsumer, null); } @@ -2900,16 +2901,16 @@ public final Disposable subscribe( * @return a new {@link Disposable} that can be used to cancel the underlying {@link Subscription} */ public final Disposable subscribe( - @Nullable Consumer consumer, - @Nullable Consumer errorConsumer, + @Nullable Consumer consumer, + @Nullable Consumer errorConsumer, @Nullable Runnable completeConsumer, - @Nullable Consumer subscriptionConsumer) { + @Nullable Consumer subscriptionConsumer) { return subscribeWith(new LambdaMonoSubscriber<>(consumer, errorConsumer, completeConsumer, subscriptionConsumer)); } @Override - public final void subscribe(Subscriber actual) { + public final void subscribe(Subscriber actual) { onLastAssembly(this).subscribe(Operators.toCoreSubscriber(actual)); } @@ -2923,7 +2924,7 @@ public final void subscribe(Subscriber actual) { * @param actual the {@link Subscriber} interested into the published sequence * @see Publisher#subscribe(Subscriber) */ - public abstract void subscribe(CoreSubscriber actual); + public abstract void subscribe(CoreSubscriber actual); /** * Enrich a potentially empty downstream {@link Context} by adding all values @@ -2945,7 +2946,7 @@ public final void subscribe(Subscriber actual) { * @return a contextualized {@link Mono} * @see Context */ - public final Mono subscriberContext(Context mergeContext) { + public final Mono<@NonNull T> subscriberContext(Context mergeContext) { return subscriberContext(c -> c.putAll(mergeContext)); } @@ -2968,7 +2969,7 @@ public final Mono subscriberContext(Context mergeContext) { * @return a contextualized {@link Mono} * @see Context */ - public final Mono subscriberContext(Function doOnContext) { + public final Mono<@NonNull T> subscriberContext(Function<@NonNull Context, @NonNull Context> doOnContext) { return new MonoSubscriberContext<>(this, doOnContext); } @@ -2989,7 +2990,7 @@ public final Mono subscriberContext(Function doOnContext) { * @return a {@link Flux} requesting asynchronously * @see #publishOn(Scheduler) */ - public final Mono subscribeOn(Scheduler scheduler) { + public final Mono<@NonNull T> subscribeOn(Scheduler scheduler) { if(this instanceof Callable) { if (this instanceof Fuseable.ScalarCallable) { try { @@ -3017,7 +3018,7 @@ public final Mono subscribeOn(Scheduler scheduler) { * * @return the passed {@link Subscriber} after subscribing it to this {@link Mono} */ - public final > E subscribeWith(E subscriber) { + public final > E subscribeWith(E subscriber) { subscribe(subscriber); return subscriber; } @@ -3033,7 +3034,7 @@ public final > E subscribeWith(E subscriber) { * @return a {@link Mono} falling back upon source completing without elements * @see Flux#switchIfEmpty */ - public final Mono switchIfEmpty(Mono alternate) { + public final Mono<@NonNull T> switchIfEmpty(Mono alternate) { return onAssembly(new MonoSwitchIfEmpty<>(this, alternate)); } @@ -3047,7 +3048,7 @@ public final Mono switchIfEmpty(Mono alternate) { * @param value a tag value * @return the same sequence, but bearing tags */ - public final Mono tag(String key, String value) { + public final Mono<@NonNull T> tag(String key, String value) { return MonoName.createOrAppend(this, key, value); } @@ -3062,7 +3063,7 @@ public final Mono tag(String key, String value) { * @return a new {@link Mono} that will propagate the signals from the source unless * no signal is received for {@code duration}, in which case it completes. */ - public final Mono take(Duration duration) { + public final Mono<@NonNull T> take(Duration duration) { return take(duration, Schedulers.parallel()); } @@ -3079,7 +3080,7 @@ public final Mono take(Duration duration) { * @return a new {@link Mono} that will propagate the signals from the source unless * no signal is received for {@code duration}, in which case it completes. */ - public final Mono take(Duration duration, Scheduler timer) { + public final Mono<@NonNull T> take(Duration duration, Scheduler timer) { return takeUntilOther(Mono.delay(duration, timer)); } @@ -3095,7 +3096,7 @@ public final Mono take(Duration duration, Scheduler timer) { * a signal is first received from the companion {@link Publisher}, in which case it * completes. */ - public final Mono takeUntilOther(Publisher other) { + public final Mono<@NonNull T> takeUntilOther(Publisher<@NonNull ?> other) { return onAssembly(new MonoTakeUntilOther<>(this, other)); } @@ -3108,7 +3109,7 @@ public final Mono takeUntilOther(Publisher other) { *

* @return a {@link Mono} ignoring its payload (actively dropping) */ - public final Mono then() { + public final Mono<@NonNull Void> then() { return empty(this); } @@ -3127,7 +3128,7 @@ public final Mono then() { * * @return a new {@link Mono} that emits from the supplied {@link Mono} */ - public final Mono then(Mono other) { + public final Mono<@NonNull V> then(Mono<@NonNull V> other) { if (this instanceof MonoIgnoreThen) { MonoIgnoreThen a = (MonoIgnoreThen) this; return a.shift(other); @@ -3147,7 +3148,7 @@ public final Mono then(Mono other) { * @return a new {@link Mono} completing when both publishers have completed in * sequence */ - public final Mono thenEmpty(Publisher other) { + public final Mono<@NonNull Void> thenEmpty(Publisher<@NonNull Void> other) { return then(fromDirect(other)); } @@ -3166,7 +3167,7 @@ public final Mono thenEmpty(Publisher other) { * @return a new {@link Flux} that emits from the supplied {@link Publisher} after * this Mono completes. */ - public final Flux thenMany(Publisher other) { + public final Flux<@NonNull V> thenMany(Publisher<@NonNull V> other) { @SuppressWarnings("unchecked") Flux concat = (Flux)Flux.concat(ignoreElement(), other); return Flux.onAssembly(concat); @@ -3183,7 +3184,7 @@ public final Flux thenMany(Publisher other) { * * @return a {@link Mono} that can time out */ - public final Mono timeout(Duration timeout) { + public final Mono<@NonNull T> timeout(Duration timeout) { return timeout(timeout, Schedulers.parallel()); } @@ -3201,7 +3202,7 @@ public final Mono timeout(Duration timeout) { * * @return a {@link Mono} that will fallback to a different {@link Mono} in case of timeout */ - public final Mono timeout(Duration timeout, Mono fallback) { + public final Mono<@NonNull T> timeout(Duration timeout, @Nullable Mono fallback) { return timeout(timeout, fallback, Schedulers.parallel()); } @@ -3217,7 +3218,7 @@ public final Mono timeout(Duration timeout, Mono fallback) { * * @return an expirable {@link Mono} */ - public final Mono timeout(Duration timeout, Scheduler timer) { + public final Mono<@NonNull T> timeout(Duration timeout, Scheduler timer) { return timeout(timeout, null, timer); } @@ -3236,7 +3237,7 @@ public final Mono timeout(Duration timeout, Scheduler timer) { * * @return an expirable {@link Mono} with a fallback {@link Mono} */ - public final Mono timeout(Duration timeout, @Nullable Mono fallback, + public final Mono<@NonNull T> timeout(Duration timeout, @Nullable Mono fallback, Scheduler timer) { final Mono _timer = Mono.delay(timeout, timer).onErrorReturn(0L); @@ -3259,7 +3260,7 @@ public final Mono timeout(Duration timeout, @Nullable Mono fallb * @return an expirable {@link Mono} if the item does not come before a {@link Publisher} signals * */ - public final Mono timeout(Publisher firstTimeout) { + public final Mono<@NonNull T> timeout(Publisher<@NonNull U> firstTimeout) { return onAssembly(new MonoTimeout<>(this, firstTimeout)); } @@ -3279,7 +3280,7 @@ public final Mono timeout(Publisher firstTimeout) { * come before a {@link Publisher} signals * */ - public final Mono timeout(Publisher firstTimeout, Mono fallback) { + public final Mono<@NonNull T> timeout(Publisher<@NonNull U> firstTimeout, Mono fallback) { return onAssembly(new MonoTimeout<>(this, firstTimeout, fallback)); } @@ -3293,7 +3294,7 @@ public final Mono timeout(Publisher firstTimeout, Mono fa * * @return a timestamped {@link Mono} */ - public final Mono> timestamp() { + public final Mono<@NonNull Tuple2<@NonNull Long, @NonNull T>> timestamp() { return timestamp(Schedulers.parallel()); } @@ -3308,7 +3309,7 @@ public final Mono> timestamp() { * @param scheduler a {@link Scheduler} instance to read time from * @return a timestamped {@link Mono} */ - public final Mono> timestamp(Scheduler scheduler) { + public final Mono<@NonNull Tuple2<@NonNull Long, @NonNull T>> timestamp(Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler"); return map(d -> Tuples.of(scheduler.now(TimeUnit.MILLISECONDS), d)); } @@ -3323,7 +3324,7 @@ public final Mono> timestamp(Scheduler scheduler) { * * @return a {@link CompletableFuture} */ - public final CompletableFuture toFuture() { + public final CompletableFuture<@Nullable T> toFuture() { return subscribeWith(new MonoToCompletableFuture<>()); } @@ -3339,7 +3340,7 @@ public final CompletableFuture toFuture() { * * @return a {@link MonoProcessor} to use to either retrieve value or cancel the underlying {@link Subscription} */ - public final MonoProcessor toProcessor() { + public final MonoProcessor<@NonNull T> toProcessor() { MonoProcessor result; if (this instanceof MonoProcessor) { result = (MonoProcessor)this; @@ -3371,7 +3372,7 @@ public final MonoProcessor toProcessor() { * @see #compose(Function) compose(Function) for deferred composition of {@link Mono} for each {@link Subscriber} * @see #as(Function) as(Function) for a loose conversion to an arbitrary type */ - public final Mono transform(Function, ? extends Publisher> transformer) { + public final Mono<@NonNull V> transform(Function, ? extends @NonNull Publisher<@NonNull V>> transformer) { return onAssembly(from(transformer.apply(this))); } @@ -3424,7 +3425,7 @@ public final Mono zipWhen(Function> rightGenera * * @return a new combined Mono */ - public final Mono> zipWith(Mono other) { + public final Mono<@NonNull Tuple2<@NonNull T, @NonNull T2>> zipWith(Mono other) { return zipWith(other, Flux.tuple2Function()); } @@ -3443,7 +3444,7 @@ public final Mono> zipWith(Mono other) { * * @return a new combined Mono */ - public final Mono zipWith(Mono other, + public final Mono<@NonNull O> zipWith(Mono other, BiFunction combinator) { if (this instanceof MonoZip) { @SuppressWarnings("unchecked") MonoZip o = (MonoZip) this; @@ -3468,7 +3469,7 @@ public final Mono zipWith(Mono other, * @return the source, potentially wrapped with assembly time cross-cutting behavior */ @SuppressWarnings("unchecked") - protected static Mono onAssembly(Mono source) { + protected static Mono<@NonNull T> onAssembly(Mono<@NonNull T> source) { Function hook = Hooks.onEachOperatorHook; if(hook == null) { return source; @@ -3488,7 +3489,7 @@ protected static Mono onAssembly(Mono source) { * @return the source, potentially wrapped with assembly time cross-cutting behavior */ @SuppressWarnings("unchecked") - protected static Mono onLastAssembly(Mono source) { + protected static Mono<@NonNull T> onLastAssembly(Mono<@NonNull T> source) { Function hook = Hooks.onLastOperatorHook; if(hook == null) { return source; @@ -3509,7 +3510,7 @@ static Mono empty(Publisher source) { } @SuppressWarnings("unchecked") - static Mono doOnSignal(Mono source, + static Mono<@NonNull T> doOnSignal(Mono source, @Nullable Consumer onSubscribe, @Nullable Consumer onNext, @Nullable Consumer onError, diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java b/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java index dec5d2fa89..d28ba343a7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java @@ -17,11 +17,11 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits a single boolean true if all values of the source sequence match diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java b/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java index 30757bf428..85491b2ece 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java @@ -17,11 +17,11 @@ import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits a single boolean true if any of the values of the source sequence match diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java index c1dbd89041..4e46b73856 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java @@ -19,13 +19,13 @@ import java.time.Duration; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.scheduler.Scheduler; import reactor.util.Logger; import reactor.util.Loggers; +import reactor.util.annotation.Nullable; /** * An operator that caches the value from a source Mono with a TTL, after which the value diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCallableOnAssembly.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCallableOnAssembly.java index 49070d2c6e..8f85c77944 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCallableOnAssembly.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCallableOnAssembly.java @@ -18,12 +18,12 @@ import java.time.Duration; import java.util.concurrent.Callable; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.core.publisher.FluxOnAssembly.AssemblySnapshotException; +import reactor.util.annotation.Nullable; /** * Captures the current stacktrace when this publisher is created and makes it diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java index 7e612fffa7..1ab6f03a71 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java @@ -19,11 +19,11 @@ import java.util.Objects; import java.util.function.BiConsumer; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Collects the values of the source sequence into a container returned by diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java index 0dc8f08837..8a92cc5ef9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java @@ -19,11 +19,11 @@ import java.util.Collection; import java.util.Objects; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Buffers all values from the source Publisher and emits it as a single Collection. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCount.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCount.java index 615c85f31c..df03d26e25 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCount.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCount.java @@ -15,11 +15,11 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Counts the number of values in the source sequence. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java index ac7b0bca06..00b46d0f40 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java @@ -22,12 +22,12 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.publisher.FluxCreate.SinkDisposable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Wraps a the downstream Subscriber into a single emission object and calls the given diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java index 3b8d25a457..e6d4a3961f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java @@ -19,13 +19,13 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.Disposables; import reactor.core.Exceptions; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * Emits a single 0L value delayed by some time amount with a help of diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java index 761dcd17ee..3a9ae2f81c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java @@ -19,12 +19,12 @@ import java.util.Objects; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * Emits the first value emitted by a given source publisher, delayed by some time amount diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayUntil.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayUntil.java index d4a13b7687..cde071e431 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayUntil.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayUntil.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -29,6 +28,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Waits for a Mono source to terminate or produce a value, in which case the value is diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java b/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java index ebc67c598b..d8d325e883 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Emits only the element at the given index position or signals a diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoEmpty.java b/reactor-core/src/main/java/reactor/core/publisher/MonoEmpty.java index bd1c0f2f16..59f122b6f2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoEmpty.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoEmpty.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.time.Duration; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Represents an empty publisher which only calls onSubscribe and onComplete. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java index db415cefa5..0f70f0ab2f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -29,6 +28,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Maps the upstream value into a single {@code true} or {@code false} value diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java index 348c123702..c184cc4c0b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java @@ -18,10 +18,10 @@ import java.util.Iterator; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Given a push of source Publishers the values of that Publisher is forwarded to the diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java index a8e21f3bab..5dd72d550b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java @@ -21,13 +21,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Given a Mono source, applies a function on its single item and continues diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java index 0d8532ad6d..1de27cdf74 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java @@ -22,13 +22,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; final class MonoFlatMapMany extends FluxFromMonoOperator { diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFromFluxOperator.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFromFluxOperator.java index 860dccb52c..2474285355 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFromFluxOperator.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFromFluxOperator.java @@ -17,10 +17,10 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A decorating {@link Mono} {@link Publisher} that exposes {@link Mono} API over an diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFromPublisher.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFromPublisher.java index 09c6393cdc..3ed7273705 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFromPublisher.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFromPublisher.java @@ -17,11 +17,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Emits a single item at most from the source. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoHasElement.java b/reactor-core/src/main/java/reactor/core/publisher/MonoHasElement.java index d8c8664c8d..ca9899da3c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoHasElement.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoHasElement.java @@ -15,11 +15,11 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * @see Reactive-Streams-Commons diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoHasElements.java b/reactor-core/src/main/java/reactor/core/publisher/MonoHasElements.java index 9b570b41b8..4dff4a6760 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoHasElements.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoHasElements.java @@ -15,11 +15,11 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * @see Reactive-Streams-Commons diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreElements.java b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreElements.java index 7080623d3a..294b85def3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreElements.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreElements.java @@ -15,10 +15,10 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Ignores normal values and passes only the terminal signals along. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnorePublisher.java b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnorePublisher.java index 846fde19e3..91af969d5b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnorePublisher.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnorePublisher.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Ignores normal values and passes only the terminal signals along. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java index 3615db7a85..3624d884bd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -29,6 +28,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Concatenates a several Mono sources with a final Mono source by diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoName.java b/reactor-core/src/main/java/reactor/core/publisher/MonoName.java index 1807ed0d49..2dd0dccfd7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoName.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoName.java @@ -20,12 +20,12 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import reactor.util.annotation.Nullable; /** * An operator that just bears a name or a set of tags, which can be retrieved via the diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoNameFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoNameFuseable.java index 084fa8689f..6c37b5cf1a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoNameFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoNameFuseable.java @@ -17,11 +17,11 @@ package reactor.core.publisher; import java.util.Set; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.util.function.Tuple2; +import reactor.util.annotation.Nullable; /** * An operator that just bears a name or a set of tags, which can be retrieved via the diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java b/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java index 029cffc5d1..c35ec1e6cb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java @@ -17,10 +17,10 @@ package reactor.core.publisher; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Emits a single item at most from the source. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoOnAssembly.java b/reactor-core/src/main/java/reactor/core/publisher/MonoOnAssembly.java index 1adecea56d..4b1d901540 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoOnAssembly.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoOnAssembly.java @@ -16,11 +16,11 @@ package reactor.core.publisher; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.publisher.FluxOnAssembly.AssemblySnapshotException; +import reactor.util.annotation.Nullable; /** * Captures the current stacktrace when this publisher is created and makes it diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoOperator.java b/reactor-core/src/main/java/reactor/core/publisher/MonoOperator.java index 792a303db4..f6b860e887 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoOperator.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoOperator.java @@ -17,14 +17,11 @@ package reactor.core.publisher; import java.util.Objects; -import java.util.function.BiFunction; -import java.util.function.Function; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; -import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A decorating {@link Mono} {@link Publisher} that exposes {@link Mono} API over an diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPeek.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPeek.java index 5fbb31ef7c..148050069e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPeek.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPeek.java @@ -17,12 +17,12 @@ import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable.ConditionalSubscriber; import reactor.core.publisher.FluxPeekFuseable.PeekConditionalSubscriber; +import reactor.util.annotation.Nullable; /** * Peeks out values that make a filter function return false. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekFuseable.java index d6b1a1b549..b8b435e6bb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekFuseable.java @@ -18,11 +18,11 @@ import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Peeks out values that make a filter function return false. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java index 05687e0716..cb55f6d1ee 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java @@ -18,12 +18,12 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Peeks the value of a {@link Mono} and execute terminal callbacks accordingly, allowing diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java index 941c9aa715..34a85a1a6e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.LongSupplier; -import javax.annotation.Nullable; import org.reactivestreams.Processor; import org.reactivestreams.Publisher; @@ -33,7 +32,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.concurrent.WaitStrategy; -import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * A {@code MonoProcessor} is a {@link Mono} extension that implements stateful semantics. Multi-subscribe is allowed. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java index aa9fffcfaf..2ee6fc68b7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java @@ -18,12 +18,12 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * Schedules the emission of the value or completion of the wrapped Mono via diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java b/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java index f1b0f36a91..ab1c45f3f5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java @@ -18,11 +18,11 @@ import java.util.Objects; import java.util.function.BiFunction; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Aggregates the source items with an aggregator function and returns the last result. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java b/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java index 98395668ae..f9c2cbca73 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java @@ -19,11 +19,11 @@ import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Aggregates the source values with the help of an accumulator diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java index b874f2c054..40afbd34fc 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java @@ -19,9 +19,9 @@ import java.time.Duration; import java.util.Objects; import java.util.concurrent.Callable; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Executes the runnable whenever a Subscriber subscribes to this Mono. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java index e594bc6aea..d89162b37f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.BiPredicate; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -30,6 +29,7 @@ import reactor.core.Scannable; import reactor.util.concurrent.Queues; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; import static reactor.core.publisher.Operators.cancelledSubscription; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java index b6aae1526d..8e56c3cc3b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java @@ -18,11 +18,11 @@ import java.util.NoSuchElementException; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Expects and emits a single item from the source or signals diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java index 04e1668e37..e8c1d3a0ca 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java @@ -19,11 +19,11 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Disposable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Wrapper API around an actual downstream Subscriber diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSource.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSource.java index fc8e07c08a..47eafe3d8c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSource.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSource.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * A decorating {@link Mono} {@link Publisher} that exposes {@link Mono} API over an arbitrary {@link Publisher} diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSourceFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSourceFuseable.java index 5c8a4e0b55..0608d73b43 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSourceFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSourceFuseable.java @@ -16,12 +16,12 @@ package reactor.core.publisher; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java b/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java index f8ecf67f8a..26344b9892 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java @@ -20,11 +20,11 @@ import java.util.function.BiConsumer; import java.util.function.Function; import java.util.stream.Collector; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Collects the values from the source sequence into a {@link java.util.stream.Collector} diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java index 98d666a89a..1710292007 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java @@ -19,13 +19,13 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Scheduler.Worker; +import reactor.util.annotation.Nullable; /** * Subscribes to the upstream Mono on the specified Scheduler and makes sure diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java index 68478b711a..54db0a06cc 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java @@ -18,12 +18,12 @@ import java.util.Objects; import java.util.concurrent.RejectedExecutionException; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.publisher.FluxSubscribeOnValue.ScheduledEmpty; import reactor.core.publisher.FluxSubscribeOnValue.ScheduledScalar; import reactor.core.scheduler.Scheduler; +import reactor.util.annotation.Nullable; /** * Mono indicating a scalar/empty source that subscribes on the specified scheduler. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java b/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java index 796a0017b6..ed7376dbe8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java @@ -17,11 +17,11 @@ import java.util.NoSuchElementException; import java.util.Objects; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; +import reactor.util.annotation.Nullable; /** * Take the very last value from a Publisher source and and emit that one. diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoTakeUntilOther.java b/reactor-core/src/main/java/reactor/core/publisher/MonoTakeUntilOther.java index 41310062ed..fa74f9ae15 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoTakeUntilOther.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoTakeUntilOther.java @@ -19,7 +19,6 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java b/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java index ee57a07e07..3d52f25be4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java @@ -22,7 +22,6 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; @@ -30,6 +29,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Waits for all Mono sources to produce a value or terminate, and if all of them produced diff --git a/reactor-core/src/main/java/reactor/core/publisher/OperatorDisposables.java b/reactor-core/src/main/java/reactor/core/publisher/OperatorDisposables.java index d52210cf59..f7f382c578 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/OperatorDisposables.java +++ b/reactor-core/src/main/java/reactor/core/publisher/OperatorDisposables.java @@ -19,10 +19,10 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import reactor.core.Disposable; import reactor.core.Disposables; +import reactor.util.annotation.Nullable; /** * Utility methods to work with {@link Disposable} atomically. diff --git a/reactor-core/src/main/java/reactor/core/publisher/Operators.java b/reactor-core/src/main/java/reactor/core/publisher/Operators.java index 1e345d75a9..7fd5dd0ee9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Operators.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Operators.java @@ -24,7 +24,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -36,6 +35,8 @@ import reactor.util.Logger; import reactor.util.Loggers; import reactor.util.context.Context; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * An helper to support "Operator" writing, handle noop subscriptions, validate request @@ -97,7 +98,7 @@ public static long addCap(long a, long b) { */ @SuppressWarnings("unchecked") @Nullable - public static Fuseable.QueueSubscription as(Subscription s) { + public static Fuseable.QueueSubscription<@NonNull T> as(Subscription s) { if (s instanceof Fuseable.QueueSubscription) { return (Fuseable.QueueSubscription) s; } @@ -123,7 +124,7 @@ public static Subscription cancelledSubscription() { * * @param s the target subscriber */ - public static void complete(Subscriber s) { + public static void complete(Subscriber<@NonNull ?> s) { s.onSubscribe(EmptySubscription.INSTANCE); s.onComplete(); } @@ -136,7 +137,7 @@ public static void complete(Subscriber s) { * @return a new {@link Subscriber} whose sole purpose is to request Long.MAX */ @SuppressWarnings("unchecked") - public static CoreSubscriber drainSubscriber() { + public static CoreSubscriber<@NonNull T> drainSubscriber() { return (CoreSubscriber)DrainSubscriber.INSTANCE; } @@ -148,7 +149,7 @@ public static CoreSubscriber drainSubscriber() { * @return a placeholder subscriber */ @SuppressWarnings("unchecked") - public static CoreSubscriber emptySubscriber() { + public static CoreSubscriber<@NonNull T> emptySubscriber() { return (CoreSubscriber) EMPTY_SUBSCRIBER; } @@ -173,7 +174,7 @@ public static Subscription emptySubscription() { * @param s target Subscriber to error * @param e the actual error */ - public static void error(Subscriber s, Throwable e) { + public static void error(Subscriber<@NonNull ?> s, Throwable e) { s.onSubscribe(EmptySubscription.INSTANCE); s.onError(e); } @@ -217,7 +218,7 @@ public static long getAndAddCap(AtomicLongFieldUpdater updater, T instanc * * @return a new {@link Function} */ - public static Function, ? extends Publisher> lift(BiFunction, ? extends CoreSubscriber> lifter) { + public static Function, ? extends @NonNull Publisher<@NonNull O>> lift(BiFunction<@NonNull Scannable, ? super @NonNull CoreSubscriber, ? extends @NonNull CoreSubscriber> lifter) { return new LiftFunction<>(null, lifter); } @@ -243,7 +244,7 @@ public static long getAndAddCap(AtomicLongFieldUpdater updater, T instanc * * @return a new {@link Function} */ - public static Function, ? extends Publisher> lift( + public static Function, ? extends @NonNull Publisher<@NonNull O>> lift( Predicate filter, BiFunction, ? extends CoreSubscriber> lifter) { return new LiftFunction<>(filter, lifter); diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java index a91922f436..8f52f22b49 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java @@ -19,13 +19,13 @@ import java.util.Objects; import java.util.function.BiConsumer; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Reduce the sequence of values in each 'rail' to a single value. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelConcatMap.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelConcatMap.java index 6cf7b4021c..b26044f553 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelConcatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelConcatMap.java @@ -19,12 +19,12 @@ import java.util.Queue; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.core.publisher.FluxConcatMap.ErrorMode; +import reactor.util.annotation.Nullable; /** * Concatenates the generated Publishers on each rail. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelFilter.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelFilter.java index 4238601ced..b3e8959c0d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelFilter.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelFilter.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.function.Predicate; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Filters each 'rail' of the source ParallelFlux with a predicate function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelFlatMap.java index d8ce1b9e5a..ff3db4ee94 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelFlatMap.java @@ -18,11 +18,11 @@ import java.util.Queue; import java.util.function.Function; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Flattens the generated Publishers on each rail. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelFlux.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelFlux.java index 570b7782be..4b693518bd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelFlux.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelFlux.java @@ -31,7 +31,6 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.logging.Level; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -44,6 +43,8 @@ import reactor.core.scheduler.Scheduler; import reactor.util.Logger; import reactor.util.concurrent.Queues; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A ParallelFlux publishes to an array of Subscribers, in parallel 'rails' (or @@ -74,7 +75,7 @@ public abstract class ParallelFlux implements Publisher { * * @return the {@link ParallelFlux} instance */ - public static ParallelFlux from(Publisher source) { + public static ParallelFlux<@NonNull T> from(Publisher source) { return from(source, Runtime.getRuntime() .availableProcessors(), Queues.SMALL_BUFFER_SIZE, @@ -91,7 +92,7 @@ public static ParallelFlux from(Publisher source) { * * @return the new {@link ParallelFlux} instance */ - public static ParallelFlux from(Publisher source, + public static ParallelFlux<@NonNull T> from(Publisher source, int parallelism) { return from(source, parallelism, Queues.SMALL_BUFFER_SIZE, @@ -112,7 +113,7 @@ public static ParallelFlux from(Publisher source, * * @return the new {@link ParallelFlux} instance */ - public static ParallelFlux from(Publisher source, + public static ParallelFlux<@NonNull T> from(Publisher source, int parallelism, int prefetch, Supplier> queueSupplier) { @@ -134,7 +135,7 @@ public static ParallelFlux from(Publisher source, * @return the new {@link ParallelFlux} instance */ @SafeVarargs - public static ParallelFlux from(Publisher... publishers) { + public static ParallelFlux<@NonNull T> from(Publisher @NonNull ... publishers) { return onAssembly(new ParallelArraySource<>(publishers)); } @@ -147,7 +148,7 @@ public static ParallelFlux from(Publisher... publishers) { * * @return the value returned by the converter function */ - public final U as(Function, U> converter) { + public final U as(Function, @NonNull U> converter) { return converter.apply(this); } @@ -161,7 +162,7 @@ public final U as(Function, U> converter) { * * @return the assembly tracing {@link ParallelFlux} */ - public final ParallelFlux checkpoint() { + public final ParallelFlux<@NonNull T> checkpoint() { return new ParallelFluxOnAssembly<>(this, null); } @@ -181,7 +182,7 @@ public final ParallelFlux checkpoint() { * @param description a unique enough description to include in the light assembly traceback. * @return the assembly marked {@link ParallelFlux} */ - public final ParallelFlux checkpoint(String description) { + public final ParallelFlux<@NonNull T> checkpoint(String description) { return new ParallelFluxOnAssembly<>(this, description, true); } @@ -211,7 +212,7 @@ public final ParallelFlux checkpoint(String description) { * to use a stack trace. * @return the assembly marked {@link ParallelFlux}. */ - public final ParallelFlux checkpoint(String description, boolean forceStackTrace) { + public final ParallelFlux<@NonNull T> checkpoint(String description, boolean forceStackTrace) { return new ParallelFluxOnAssembly<>(this, description, !forceStackTrace); } @@ -227,8 +228,8 @@ public final ParallelFlux checkpoint(String description, boolean forceStackTr * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux collect(Supplier collectionSupplier, - BiConsumer collector) { + public final ParallelFlux<@NonNull C> collect(Supplier collectionSupplier, + BiConsumer collector) { return onAssembly(new ParallelCollect<>(this, collectionSupplier, collector)); } @@ -242,7 +243,7 @@ public final ParallelFlux collect(Supplier collectionSupplie * * @return the new Flux instance */ - public final Mono> collectSortedList(Comparator comparator) { + public final Mono<@NonNull List<@NonNull T>> collectSortedList(Comparator comparator) { return collectSortedList(comparator, 16); } @@ -257,7 +258,7 @@ public final Mono> collectSortedList(Comparator comparator) { * * @return the new Mono instance */ - public final Mono> collectSortedList(Comparator comparator, + public final Mono<@NonNull List<@NonNull T>> collectSortedList(Comparator comparator, int capacityHint) { int ch = capacityHint / parallelism() + 1; ParallelFlux> railReduced = @@ -288,7 +289,7 @@ public final Mono> collectSortedList(Comparator comparator, * @param the type of the resulting parallelized flux * @return a {@link ParallelFlux} of the composed groups */ - public final ParallelFlux composeGroup(Function, + public final ParallelFlux<@NonNull U> composeGroup(Function, ? extends Publisher> composer) { return from(groups().flatMap(composer::apply)); } @@ -303,7 +304,7 @@ public final ParallelFlux composeGroup(Function ParallelFlux concatMap(Function> mapper) { + public final ParallelFlux<@NonNull R> concatMap(Function> mapper) { return concatMap(mapper, 2, ErrorMode.IMMEDIATE); } @@ -318,7 +319,7 @@ public final ParallelFlux concatMap(Function ParallelFlux concatMap(Function> mapper, + public final ParallelFlux<@NonNull R> concatMap(Function> mapper, int prefetch) { return concatMap(mapper, prefetch, ErrorMode.IMMEDIATE); } @@ -333,8 +334,8 @@ public final ParallelFlux concatMap(Function ParallelFlux concatMapDelayError(Function> mapper) { + public final ParallelFlux<@NonNull R> concatMapDelayError(Function> mapper) { return concatMap(mapper, 2, ErrorMode.END); } @@ -345,7 +346,7 @@ public final ParallelFlux concatMapDelayError(Function doAfterTerminate(Runnable afterTerminate) { + public final ParallelFlux<@NonNull T> doAfterTerminate(Runnable afterTerminate) { Objects.requireNonNull(afterTerminate, "afterTerminate"); return doOnSignal(this, null, null, null, null, afterTerminate, null, null, null); } @@ -357,7 +358,7 @@ public final ParallelFlux doAfterTerminate(Runnable afterTerminate) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux doOnCancel(Runnable onCancel) { + public final ParallelFlux<@NonNull T> doOnCancel(Runnable onCancel) { Objects.requireNonNull(onCancel, "onCancel"); return doOnSignal(this, null, null, null, null, null, null, null, onCancel); } @@ -369,7 +370,7 @@ public final ParallelFlux doOnCancel(Runnable onCancel) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux doOnComplete(Runnable onComplete) { + public final ParallelFlux<@NonNull T> doOnComplete(Runnable onComplete) { Objects.requireNonNull(onComplete, "onComplete"); return doOnSignal(this, null, null, null, onComplete, null, null, null, null); } @@ -397,7 +398,7 @@ public final ParallelFlux doOnComplete(Runnable onComplete) { * @see #subscribe(CoreSubscriber[]) * @see Signal */ - public final ParallelFlux doOnEach(Consumer> signalConsumer) { + public final ParallelFlux<@NonNull T> doOnEach(Consumer> signalConsumer) { Objects.requireNonNull(signalConsumer, "signalConsumer"); return doOnSignal(this, v -> signalConsumer.accept(Signal.next(v)), @@ -414,7 +415,7 @@ public final ParallelFlux doOnEach(Consumer> signalConsumer * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux doOnError(Consumer onError) { + public final ParallelFlux<@NonNull T> doOnError(Consumer onError) { Objects.requireNonNull(onError, "onError"); return doOnSignal(this, null, null, onError, null, null, null, null, null); } @@ -427,7 +428,7 @@ public final ParallelFlux doOnError(Consumer onError) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux doOnSubscribe(Consumer onSubscribe) { + public final ParallelFlux<@NonNull T> doOnSubscribe(Consumer onSubscribe) { Objects.requireNonNull(onSubscribe, "onSubscribe"); return doOnSignal(this, null, null, null, null, null, onSubscribe, null, null); } @@ -439,7 +440,7 @@ public final ParallelFlux doOnSubscribe(Consumer onSubs * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux doOnNext(Consumer onNext) { + public final ParallelFlux<@NonNull T> doOnNext(Consumer onNext) { Objects.requireNonNull(onNext, "onNext"); return doOnSignal(this, onNext, null, null, null, null, null, null, null); } @@ -452,7 +453,7 @@ public final ParallelFlux doOnNext(Consumer onNext) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux doOnRequest(LongConsumer onRequest) { + public final ParallelFlux<@NonNull T> doOnRequest(LongConsumer onRequest) { Objects.requireNonNull(onRequest, "onRequest"); return doOnSignal(this, null, null, null, null, null, null, onRequest, null); } @@ -463,7 +464,7 @@ public final ParallelFlux doOnRequest(LongConsumer onRequest) { * * @return an observed {@link ParallelFlux} */ - public final ParallelFlux doOnTerminate(Runnable onTerminate) { + public final ParallelFlux<@NonNull T> doOnTerminate(Runnable onTerminate) { Objects.requireNonNull(onTerminate, "onTerminate"); return doOnSignal(this, null, @@ -486,7 +487,7 @@ public final ParallelFlux doOnTerminate(Runnable onTerminate) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux filter(Predicate predicate) { + public final ParallelFlux<@NonNull T> filter(Predicate predicate) { Objects.requireNonNull(predicate, "predicate"); return onAssembly(new ParallelFilter<>(this, predicate)); } @@ -502,7 +503,7 @@ public final ParallelFlux filter(Predicate predicate) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux flatMap(Function> mapper) { + public final ParallelFlux<@NonNull R> flatMap(Function> mapper) { return flatMap(mapper, false, Integer.MAX_VALUE, Queues.SMALL_BUFFER_SIZE); @@ -520,7 +521,7 @@ public final ParallelFlux flatMap(Function ParallelFlux flatMap(Function> mapper, + public final ParallelFlux<@NonNull R> flatMap(Function> mapper, boolean delayError) { return flatMap(mapper, delayError, @@ -542,7 +543,7 @@ public final ParallelFlux flatMap(Function ParallelFlux flatMap(Function> mapper, + public final ParallelFlux<@NonNull R> flatMap(Function> mapper, boolean delayError, int maxConcurrency) { return flatMap(mapper, @@ -565,7 +566,7 @@ public final ParallelFlux flatMap(Function ParallelFlux flatMap(Function> mapper, + public final ParallelFlux<@NonNull R> flatMap(Function> mapper, boolean delayError, int maxConcurrency, int prefetch) { @@ -586,7 +587,7 @@ public final ParallelFlux flatMap(Function> groups() { + public final Flux<@NonNull GroupedFlux<@NonNull Integer, @NonNull T>> groups() { return Flux.onAssembly(new ParallelGroup<>(this)); } @@ -596,7 +597,7 @@ public final Flux> groups() { * * @return a new {@link ParallelFlux} defeating any {@link Publisher} / {@link Subscription} feature-detection */ - public final ParallelFlux hide() { + public final ParallelFlux<@NonNull T> hide() { return new ParallelFluxHide<>(this); } @@ -613,7 +614,7 @@ public final ParallelFlux hide() { * * @return a new unaltered {@link ParallelFlux} */ - public final ParallelFlux log() { + public final ParallelFlux<@NonNull T> log() { return log(null, Level.INFO); } @@ -632,7 +633,7 @@ public final ParallelFlux log() { * * @return a new unaltered {@link ParallelFlux} */ - public final ParallelFlux log(@Nullable String category) { + public final ParallelFlux<@NonNull T> log(@Nullable String category) { return log(category, Level.INFO); } @@ -660,9 +661,9 @@ public final ParallelFlux log(@Nullable String category) { * * @return a new unaltered {@link ParallelFlux} */ - public final ParallelFlux log(@Nullable String category, + public final ParallelFlux<@NonNull T> log(@Nullable String category, Level level, - SignalType... options) { + SignalType @NonNull ... options) { return log(category, level, false, options); } @@ -692,10 +693,10 @@ public final ParallelFlux log(@Nullable String category, * * @return a new unaltered {@link ParallelFlux} */ - public final ParallelFlux log(@Nullable String category, + public final ParallelFlux<@NonNull T> log(@Nullable String category, Level level, boolean showOperatorLine, - SignalType... options) { + SignalType @NonNull ... options) { return onAssembly(new ParallelLog<>(this, new SignalLogger<>(this, category, level, showOperatorLine, options))); } @@ -710,7 +711,7 @@ public final ParallelFlux log(@Nullable String category, * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux map(Function mapper) { + public final ParallelFlux<@NonNull U> map(Function mapper) { Objects.requireNonNull(mapper, "mapper"); return onAssembly(new ParallelMap<>(this, mapper)); } @@ -722,7 +723,7 @@ public final ParallelFlux map(Function mapper) { * @param name a name for the sequence * @return the same sequence, but bearing a name */ - public final ParallelFlux name(String name) { + public final ParallelFlux<@NonNull T> name(String name) { return ParallelFluxName.createOrAppend(this, name); } @@ -745,7 +746,7 @@ public final ParallelFlux name(String name) { * @return the new Mono instance emitting the reduced value or empty if the * {@link ParallelFlux} was empty */ - public final Mono reduce(BiFunction reducer) { + public final Mono<@NonNull T> reduce(BiFunction<@NonNull T, @NonNull T, @NonNull T> reducer) { Objects.requireNonNull(reducer, "reducer"); return Mono.onAssembly(new ParallelMergeReduce<>(this, reducer)); } @@ -765,8 +766,8 @@ public final Mono reduce(BiFunction reducer) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux reduce(Supplier initialSupplier, - BiFunction reducer) { + public final ParallelFlux<@NonNull R> reduce(Supplier<@NonNull R> initialSupplier, + BiFunction<@NonNull R, ? super @NonNull T, @NonNull R> reducer) { Objects.requireNonNull(initialSupplier, "initialSupplier"); Objects.requireNonNull(reducer, "reducer"); return onAssembly(new ParallelReduceSeed<>(this, initialSupplier, reducer)); @@ -793,7 +794,7 @@ public final ParallelFlux reduce(Supplier initialSupplier, * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux runOn(Scheduler scheduler) { + public final ParallelFlux<@NonNull T> runOn(Scheduler scheduler) { return runOn(scheduler, Queues.SMALL_BUFFER_SIZE); } @@ -819,7 +820,7 @@ public final ParallelFlux runOn(Scheduler scheduler) { * * @return the new {@link ParallelFlux} instance */ - public final ParallelFlux runOn(Scheduler scheduler, int prefetch) { + public final ParallelFlux<@NonNull T> runOn(Scheduler scheduler, int prefetch) { Objects.requireNonNull(scheduler, "scheduler"); return onAssembly(new ParallelRunOn<>(this, scheduler, @@ -839,7 +840,7 @@ public final ParallelFlux runOn(Scheduler scheduler, int prefetch) { * * @see ParallelFlux#sequential(int) */ - public final Flux sequential() { + public final Flux<@NonNull T> sequential() { return sequential(Queues.SMALL_BUFFER_SIZE); } @@ -852,7 +853,7 @@ public final Flux sequential() { * * @return the new Flux instance */ - public final Flux sequential(int prefetch) { + public final Flux<@NonNull T> sequential(int prefetch) { return Flux.onAssembly(new ParallelMergeSequential<>(this, prefetch, Queues.get(prefetch))); @@ -868,7 +869,7 @@ public final Flux sequential(int prefetch) { * * @return the new Flux instance */ - public final Flux sorted(Comparator comparator) { + public final Flux<@NonNull T> sorted(Comparator comparator) { return sorted(comparator, 16); } @@ -883,7 +884,7 @@ public final Flux sorted(Comparator comparator) { * * @return the new Flux instance */ - public final Flux sorted(Comparator comparator, int capacityHint) { + public final Flux<@NonNull T> sorted(Comparator comparator, int capacityHint) { int ch = capacityHint / parallelism() + 1; ParallelFlux> railReduced = reduce(() -> new ArrayList<>(ch), (a, b) -> { a.add(b); @@ -904,7 +905,7 @@ public final Flux sorted(Comparator comparator, int capacityHint) * @param subscribers the subscribers array to run in parallel, the number of items * must be equal to the parallelism level of this ParallelFlux */ - protected abstract void subscribe(CoreSubscriber[] subscribers); + protected abstract void subscribe(CoreSubscriber @NonNull [] subscribers); /** * Subscribes to this {@link ParallelFlux} and triggers the execution chain for all @@ -920,7 +921,7 @@ public final Disposable subscribe(){ * * @param onNext consumer of onNext signals */ - public final Disposable subscribe(Consumer onNext){ + public final Disposable subscribe(Consumer onNext){ return subscribe(onNext, null, null); } @@ -931,7 +932,7 @@ public final Disposable subscribe(Consumer onNext){ * @param onNext consumer of onNext signals * @param onError consumer of error signal */ - public final Disposable subscribe(@Nullable Consumer onNext, Consumer + public final Disposable subscribe(@Nullable Consumer onNext, Consumer onError){ return subscribe(onNext, onError, null); } @@ -945,8 +946,8 @@ public final Disposable subscribe(@Nullable Consumer onNext, Consumer * @param onComplete callback on completion signal */ public final Disposable subscribe( - @Nullable Consumer onNext, - @Nullable Consumer onError, + @Nullable Consumer onNext, + @Nullable Consumer onError, @Nullable Runnable onComplete) { return subscribe(onNext, onError, onComplete, null); } @@ -962,10 +963,10 @@ public final Disposable subscribe( * @param onSubscribe consumer of the subscription signal */ public final Disposable subscribe( - @Nullable Consumer onNext, - @Nullable Consumer onError, + @Nullable Consumer onNext, + @Nullable Consumer onError, @Nullable Runnable onComplete, - @Nullable Consumer onSubscribe){ + @Nullable Consumer onSubscribe){ @SuppressWarnings("unchecked") LambdaSubscriber[] subscribers = new LambdaSubscriber[parallelism()]; @@ -988,7 +989,7 @@ public final Disposable subscribe( */ @Override @SuppressWarnings("unchecked") - public final void subscribe(Subscriber s) { + public final void subscribe(Subscriber s) { Flux.onLastAssembly(sequential()) .subscribe(new FluxHide.SuppressFuseableSubscriber<>(Operators.toCoreSubscriber(s))); } @@ -1004,7 +1005,7 @@ public final void subscribe(Subscriber s) { * @param value a tag value * @return the same sequence, but bearing tags */ - public final ParallelFlux tag(String key, String value) { + public final ParallelFlux<@NonNull T> tag(String key, String value) { return ParallelFluxName.createOrAppend(this, key, value); } @@ -1018,7 +1019,7 @@ public final ParallelFlux tag(String key, String value) { * * @return the {@link ParallelFlux} returned by the function */ - public final ParallelFlux transform(Function, ParallelFlux> composer) { + public final ParallelFlux<@NonNull U> transform(Function, @NonNull ParallelFlux<@NonNull U>> composer) { return onAssembly(as(composer)); } @@ -1035,7 +1036,7 @@ public String toString() { * * @return true if the number of subscribers equals to the parallelism level */ - protected final boolean validate(Subscriber[] subscribers) { + protected final boolean validate(Subscriber<@NonNull ?> @NonNull [] subscribers) { int p = parallelism(); if (subscribers.length != p) { IllegalArgumentException iae = new IllegalArgumentException("parallelism = " + @@ -1060,7 +1061,7 @@ protected final boolean validate(Subscriber[] subscribers) { * * @return the new {@link ParallelFlux} instance */ - final ParallelFlux concatMap(Function> mapper, + final ParallelFlux<@NonNull R> concatMap(Function> mapper, int prefetch, ErrorMode errorMode) { return onAssembly(new ParallelConcatMap<>(this, @@ -1082,8 +1083,8 @@ final ParallelFlux concatMap(Function ParallelFlux concatMapDelayError(Function> mapper, + final ParallelFlux<@NonNull R> concatMapDelayError(Function> mapper, boolean delayUntilEnd, int prefetch) { return concatMap(mapper, prefetch, delayUntilEnd ? ErrorMode.END: ErrorMode.BOUNDARY); @@ -1100,8 +1101,8 @@ final ParallelFlux concatMapDelayError(Function ParallelFlux concatMapDelayError(Function> mapper, int prefetch) { + final ParallelFlux<@NonNull R> concatMapDelayError(Function> mapper, int prefetch) { return concatMap(mapper, prefetch, ErrorMode.END); } @@ -1125,7 +1126,7 @@ public int getPrefetch() { * @return the potentially wrapped source */ @SuppressWarnings("unchecked") - protected static ParallelFlux onAssembly(ParallelFlux source) { + protected static ParallelFlux<@NonNull T> onAssembly(ParallelFlux<@NonNull T> source) { Function hook = Hooks.onEachOperatorHook; if (hook == null) { return source; @@ -1143,7 +1144,7 @@ protected static ParallelFlux onAssembly(ParallelFlux source) { * @return the potentially wrapped source */ @SuppressWarnings("unchecked") - protected static ParallelFlux onLastAssembly(ParallelFlux source) { + protected static ParallelFlux<@NonNull T> onLastAssembly(ParallelFlux<@NonNull T> source) { Function hook = Hooks.onLastOperatorHook; if (hook == null) { return source; @@ -1153,7 +1154,7 @@ protected static ParallelFlux onLastAssembly(ParallelFlux source) { } @SuppressWarnings("unchecked") - static ParallelFlux doOnSignal(ParallelFlux source, + static ParallelFlux<@NonNull T> doOnSignal(ParallelFlux<@NonNull T> source, @Nullable Consumer onNext, @Nullable Consumer onAfterNext, @Nullable Consumer onError, @@ -1173,7 +1174,7 @@ static ParallelFlux doOnSignal(ParallelFlux source, onCancel)); } - static final List sortedMerger(List a, List b, Comparator comparator) { + static final List<@NonNull T> sortedMerger(List<@NonNull T> a, List<@NonNull T> b, Comparator comparator) { int n = a.size() + b.size(); if (n == 0) { return new ArrayList<>(); diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxHide.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxHide.java index f059b7bb2e..226eb498ee 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxHide.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxHide.java @@ -16,10 +16,10 @@ package reactor.core.publisher; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Hides the identities of the upstream Publisher object and its Subscription as well. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxName.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxName.java index b7d6e85638..73f0c607bd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxName.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxName.java @@ -20,12 +20,12 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import reactor.util.annotation.Nullable; /** * Hides the identities of the upstream Publisher object and its Subscription as well. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxOnAssembly.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxOnAssembly.java index a86b56f37b..46d4d6de82 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxOnAssembly.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelFluxOnAssembly.java @@ -16,13 +16,13 @@ package reactor.core.publisher; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.publisher.FluxOnAssembly.AssemblyLightSnapshotException; import reactor.core.publisher.FluxOnAssembly.AssemblySnapshotException; +import reactor.util.annotation.Nullable; /** * Captures the current stacktrace when this connectable publisher is created and makes it diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelGroup.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelGroup.java index e99e10ee01..f2a81021cf 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelGroup.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelGroup.java @@ -18,12 +18,12 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Exposes the 'rails' as individual GroupedFlux instances, keyed by the rail index (zero based). diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelLift.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelLift.java index 7923eaa082..bf4566b9b7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelLift.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelLift.java @@ -17,10 +17,10 @@ import java.util.Objects; import java.util.function.BiFunction; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * @author Stephane Maldini diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelLog.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelLog.java index 242b74fe97..2afe9aef71 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelLog.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelLog.java @@ -15,11 +15,11 @@ */ package reactor.core.publisher; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Execute a Consumer in each 'rail' for the current element passing through. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMap.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMap.java index 16af7f3d00..ec403dfb52 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMap.java @@ -16,11 +16,11 @@ package reactor.core.publisher; import java.util.function.Function; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Maps each 'rail' of the source ParallelFlux with a mapper function. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java index f18d540419..1289c064b7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java @@ -20,13 +20,13 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.BiFunction; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Reduces all 'rails' into a single value which then gets reduced into a single diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java index c803cadb44..77b0427c05 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -29,6 +28,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Merges the individual 'rails' of the source ParallelFlux, unordered, diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java index 77f9202c2e..8edf7d2e72 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java @@ -23,13 +23,13 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Given sorted rail sequences (according to the provided comparator) as List diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelPeek.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelPeek.java index 1bda42cfa0..3020f5fbf8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelPeek.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelPeek.java @@ -17,10 +17,10 @@ import java.util.function.Consumer; import java.util.function.LongConsumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; import reactor.core.Fuseable; /** diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java index e8551aba86..045801dc1c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java @@ -19,13 +19,13 @@ import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; +import reactor.util.annotation.Nullable; /** * Reduce the sequence of values in each 'rail' to a single value. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelRunOn.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelRunOn.java index c8496997a1..8abb7b05c4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelRunOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelRunOn.java @@ -17,13 +17,13 @@ import java.util.Queue; import java.util.function.Supplier; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Scheduler.Worker; +import reactor.util.annotation.Nullable; /** * Ensures each 'rail' from upstream runs on a Worker from a Scheduler. diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java index 7eecd82c79..1f9d8bde3c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java @@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicLongArray; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -30,6 +29,7 @@ import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Dispatches the values from upstream in a round robin fashion to subscribers which are diff --git a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java index e063ba6391..424160e037 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -32,6 +31,8 @@ import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Schedulers; import reactor.util.concurrent.Queues; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; import static reactor.core.publisher.FluxReplay.ReplaySubscriber.EMPTY; import static reactor.core.publisher.FluxReplay.ReplaySubscriber.TERMINATED; @@ -61,7 +62,7 @@ public final class ReplayProcessor extends FluxProcessor * @return a new {@link ReplayProcessor} that replays its last pushed element to each new * {@link Subscriber} */ - public static ReplayProcessor cacheLast() { + public static ReplayProcessor<@NonNull T> cacheLast() { return cacheLastOrDefault(null); } @@ -81,7 +82,7 @@ public static ReplayProcessor cacheLast() { * @return a new {@link ReplayProcessor} that replays its last pushed element to each new * {@link Subscriber}, or a default one if nothing was pushed yet */ - public static ReplayProcessor cacheLastOrDefault(@Nullable T value) { + public static ReplayProcessor<@NonNull T> cacheLastOrDefault(@Nullable T value) { ReplayProcessor b = create(1); if (value != null) { b.onNext(value); @@ -98,7 +99,7 @@ public static ReplayProcessor cacheLastOrDefault(@Nullable T value) { * @return a new {@link ReplayProcessor} that replays the whole history to each new * {@link Subscriber}. */ - public static ReplayProcessor create() { + public static ReplayProcessor<@NonNull E> create() { return create(Queues.SMALL_BUFFER_SIZE, true); } @@ -112,7 +113,7 @@ public static ReplayProcessor create() { * @return a new {@link ReplayProcessor} that replays a limited history to each new * {@link Subscriber}. */ - public static ReplayProcessor create(int historySize) { + public static ReplayProcessor<@NonNull E> create(int historySize) { return create(historySize, false); } @@ -127,8 +128,8 @@ public static ReplayProcessor create(int historySize) { * @return a new {@link ReplayProcessor} that replays the whole history to each new * {@link Subscriber} if configured as unbounded, a limited history otherwise. */ - public static ReplayProcessor create(int historySize, boolean unbounded) { - FluxReplay.ReplayBuffer buffer; + public static ReplayProcessor<@NonNull E> create(int historySize, boolean unbounded) { + FluxReplay.ReplayBuffer<@NonNull E> buffer; if (unbounded) { buffer = new FluxReplay.UnboundedReplayBuffer<>(historySize); } @@ -169,7 +170,7 @@ public static ReplayProcessor create(int historySize, boolean unbounded) * * @return a new {@link ReplayProcessor} that replays elements based on their age. */ - public static ReplayProcessor createTimeout(Duration maxAge) { + public static ReplayProcessor<@NonNull T> createTimeout(Duration maxAge) { return createTimeout(maxAge, Schedulers.parallel()); } @@ -204,7 +205,7 @@ public static ReplayProcessor createTimeout(Duration maxAge) { * * @return a new {@link ReplayProcessor} that replays elements based on their age. */ - public static ReplayProcessor createTimeout(Duration maxAge, Scheduler scheduler) { + public static ReplayProcessor<@NonNull T> createTimeout(Duration maxAge, Scheduler scheduler) { return createSizeAndTimeout(Integer.MAX_VALUE, maxAge, scheduler); } @@ -242,7 +243,7 @@ public static ReplayProcessor createTimeout(Duration maxAge, Scheduler sc * @return a new {@link ReplayProcessor} that replay up to {@code size} elements, but * will evict them from its history based on their age. */ - public static ReplayProcessor createSizeAndTimeout(int size, Duration maxAge) { + public static ReplayProcessor<@NonNull T> createSizeAndTimeout(int size, Duration maxAge) { return createSizeAndTimeout(size, maxAge, Schedulers.parallel()); } @@ -280,7 +281,7 @@ public static ReplayProcessor createSizeAndTimeout(int size, Duration max * @return a new {@link ReplayProcessor} that replay up to {@code size} elements, but * will evict them from its history based on their age. */ - public static ReplayProcessor createSizeAndTimeout(int size, + public static ReplayProcessor<@NonNull T> createSizeAndTimeout(int size, Duration maxAge, Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler is null"); @@ -303,13 +304,13 @@ public static ReplayProcessor createSizeAndTimeout(int size, FluxReplay.ReplaySubscription[].class, "subscribers"); - ReplayProcessor(FluxReplay.ReplayBuffer buffer) { + ReplayProcessor(FluxReplay.ReplayBuffer<@NonNull T> buffer) { this.buffer = buffer; SUBSCRIBERS.lazySet(this, EMPTY); } @Override - public void subscribe(CoreSubscriber actual) { + public void subscribe(CoreSubscriber actual) { Objects.requireNonNull(actual, "subscribe"); FluxReplay.ReplaySubscription rs = new ReplayInner<>(actual, this); actual.onSubscribe(rs); @@ -341,7 +342,7 @@ public Object scanUnsafe(Attr key) { } @Override - public Stream inners() { + public Stream inners() { return Stream.of(subscribers); } @@ -355,7 +356,7 @@ public boolean isTerminated() { return buffer.isDone(); } - boolean add(FluxReplay.ReplaySubscription rs) { + boolean add(FluxReplay.ReplaySubscription<@NonNull T> rs) { for (; ; ) { FluxReplay.ReplaySubscription[] a = subscribers; if (a == TERMINATED) { @@ -374,7 +375,7 @@ boolean add(FluxReplay.ReplaySubscription rs) { } @SuppressWarnings("unchecked") - void remove(FluxReplay.ReplaySubscription rs) { + void remove(FluxReplay.ReplaySubscription<@NonNull T> rs) { outer: for (; ; ) { FluxReplay.ReplaySubscription[] a = subscribers; @@ -502,8 +503,8 @@ static final class ReplayInner int fusionMode; - ReplayInner(CoreSubscriber actual, - ReplayProcessor parent) { + ReplayInner(CoreSubscriber actual, + ReplayProcessor<@NonNull T> parent) { this.actual = actual; this.parent = parent; this.buffer = parent.buffer; diff --git a/reactor-core/src/main/java/reactor/core/publisher/RingBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/RingBuffer.java index 979278bf28..4592f4f1fb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/RingBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/RingBuffer.java @@ -27,7 +27,7 @@ import reactor.util.concurrent.Queues; import reactor.util.concurrent.WaitStrategy; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; import sun.misc.Unsafe; import static java.util.Arrays.copyOf; diff --git a/reactor-core/src/main/java/reactor/core/publisher/SerializedSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/SerializedSubscriber.java index f4f8b93a86..5d45711d93 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/SerializedSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/SerializedSubscriber.java @@ -16,10 +16,10 @@ package reactor.core.publisher; -import javax.annotation.Nullable; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; +import reactor.util.annotation.Nullable; /** * Subscriber that makes sure signals are delivered sequentially in case the onNext, onError or onComplete methods are diff --git a/reactor-core/src/main/java/reactor/core/publisher/Signal.java b/reactor-core/src/main/java/reactor/core/publisher/Signal.java index 58b8f6091d..8f8ca2037d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Signal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Signal.java @@ -18,10 +18,11 @@ import java.util.function.Consumer; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A domain representation of a Reactive Stream signal. @@ -42,7 +43,7 @@ public interface Signal extends Supplier, Consumer> * @return an {@code OnCompleted} variety of {@code Signal} */ @SuppressWarnings("unchecked") - static Signal complete() { + static Signal<@Nullable T> complete() { return (Signal) ImmutableSignal.ON_COMPLETE; } @@ -55,7 +56,7 @@ static Signal complete() { * * @return an {@code OnError} variety of {@code Signal} */ - static Signal error(Throwable e) { + static Signal<@Nullable T> error(Throwable e) { return new ImmutableSignal<>(SignalType.ON_ERROR, null, e, null); } @@ -78,7 +79,7 @@ static Signal next(T t) { * @param o the object to check * @return true if object represents the completion signal */ - static boolean isComplete(Object o) { + static boolean isComplete(@Nullable Object o) { return o == ImmutableSignal.ON_COMPLETE; } @@ -88,7 +89,7 @@ static boolean isComplete(Object o) { * @param o the object to check * @return true if object represents the error signal */ - static boolean isError(Object o) { + static boolean isError(@Nullable Object o) { return o instanceof Signal && ((Signal) o).getType() == SignalType.ON_ERROR; } @@ -100,7 +101,7 @@ static boolean isError(Object o) { * * @return an {@code OnSubscribe} variety of {@code Signal} */ - static Signal subscribe(Subscription subscription) { + static Signal<@Nullable T> subscribe(Subscription subscription) { return new ImmutableSignal<>(SignalType.ON_SUBSCRIBE, null, null, subscription); } @@ -205,7 +206,7 @@ default boolean isOnNext() { * @param observer the {@link Subscriber} to play the {@link Signal} on */ @Override - default void accept(Subscriber observer) { + default void accept(Subscriber observer) { if (isOnNext()) { observer.onNext(get()); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/SignalLogger.java b/reactor-core/src/main/java/reactor/core/publisher/SignalLogger.java index 8c26caec8f..d431c9354c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/SignalLogger.java +++ b/reactor-core/src/main/java/reactor/core/publisher/SignalLogger.java @@ -30,7 +30,9 @@ import reactor.util.Logger; import reactor.util.Loggers; import reactor.util.context.Context; -import javax.annotation.Nullable; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; + /** * A logging interceptor that intercepts all reactive calls and trace them. @@ -71,7 +73,7 @@ final class SignalLogger implements SignalPeek { @Nullable String category, Level level, boolean correlateStack, - SignalType... options) { + SignalType @NonNull ... options) { this(source, category, level, correlateStack, Loggers::getLogger, options); } @@ -80,7 +82,7 @@ final class SignalLogger implements SignalPeek { Level level, boolean correlateStack, Function loggerSupplier, - @Nullable SignalType... options) { + @Nullable SignalType @NonNull ... options) { this.source = Objects.requireNonNull(source, "source"); this.id = IDS.getAndIncrement(); diff --git a/reactor-core/src/main/java/reactor/core/publisher/SignalPeek.java b/reactor-core/src/main/java/reactor/core/publisher/SignalPeek.java index 3ac17c4082..b514527d9e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/SignalPeek.java +++ b/reactor-core/src/main/java/reactor/core/publisher/SignalPeek.java @@ -21,8 +21,8 @@ import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.Scannable; -import javax.annotation.Nullable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Peek into the lifecycle and sequence signals. diff --git a/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java index 06d73729ee..e3ec769f6f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java @@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -27,6 +26,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.context.Context; +import reactor.util.annotation.Nullable; /** * Reactive Streams Commons safe exit diff --git a/reactor-core/src/main/java/reactor/core/publisher/TopicProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/TopicProcessor.java index 15bba7637e..4119b2fa90 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/TopicProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/TopicProcessor.java @@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.LockSupport; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -32,6 +31,8 @@ import reactor.core.Exceptions; import reactor.util.concurrent.Queues; import reactor.util.concurrent.WaitStrategy; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** ** An implementation of a RingBuffer backed message-passing Processor implementing publish-subscribe with async event @@ -102,7 +103,7 @@ public final static class Builder { * if {@link #executor(ExecutorService)} is not configured. * @return builder with provided name */ - public Builder name(@Nullable String name) { + public Builder<@NonNull T> name(@Nullable String name) { if (executor != null) throw new IllegalArgumentException("Executor service is configured, name will not be used."); this.name = name; @@ -114,7 +115,7 @@ public Builder name(@Nullable String name) { * @param bufferSize the internal buffer size to hold signals, must be a power of 2. * @return builder with provided buffer size */ - public Builder bufferSize(int bufferSize) { + public Builder<@NonNull T> bufferSize(int bufferSize) { if (!Queues.isPowerOfTwo(bufferSize)) { throw new IllegalArgumentException("bufferSize must be a power of 2 : " + bufferSize); } @@ -133,7 +134,7 @@ public Builder bufferSize(int bufferSize) { * @param waitStrategy A RingBuffer WaitStrategy to use instead of the default blocking wait strategy. * @return builder with provided wait strategy */ - public Builder waitStrategy(@Nullable WaitStrategy waitStrategy) { + public Builder<@NonNull T> waitStrategy(@Nullable WaitStrategy waitStrategy) { this.waitStrategy = waitStrategy; return this; } @@ -143,7 +144,7 @@ public Builder waitStrategy(@Nullable WaitStrategy waitStrategy) { * @param autoCancel automatically cancel * @return builder with provided auto-cancel */ - public Builder autoCancel(boolean autoCancel) { + public Builder<@NonNull T> autoCancel(boolean autoCancel) { this.autoCancel = autoCancel; return this; } @@ -155,7 +156,7 @@ public Builder autoCancel(boolean autoCancel) { * @param executor A provided ExecutorService to manage threading infrastructure * @return builder with provided executor */ - public Builder executor(@Nullable ExecutorService executor) { + public Builder<@NonNull T> executor(@Nullable ExecutorService executor) { this.executor = executor; return this; } @@ -167,7 +168,7 @@ public Builder executor(@Nullable ExecutorService executor) { * @param requestTaskExecutor internal request executor * @return builder with provided internal request executor */ - public Builder requestTaskExecutor(@Nullable ExecutorService requestTaskExecutor) { + public Builder<@NonNull T> requestTaskExecutor(@Nullable ExecutorService requestTaskExecutor) { this.requestTaskExecutor = requestTaskExecutor; return this; } @@ -179,7 +180,7 @@ public Builder requestTaskExecutor(@Nullable ExecutorService requestTaskExecu * @param share true to support concurrent onNext calls * @return builder with specified sharing */ - public Builder share(boolean share) { + public Builder<@NonNull T> share(boolean share) { this.share = share; return this; } @@ -189,7 +190,7 @@ public Builder share(boolean share) { * @param signalSupplier A supplier of dispatched signals to preallocate * @return builder with provided signal supplier */ - public Builder signalSupplier(@Nullable Supplier signalSupplier) { + public Builder<@NonNull T> signalSupplier(@Nullable Supplier<@NonNull T> signalSupplier) { this.signalSupplier = signalSupplier; return this; } @@ -199,7 +200,7 @@ public Builder signalSupplier(@Nullable Supplier signalSupplier) { * of this builder. * @return a fresh processor */ - public TopicProcessor build() { + public TopicProcessor<@NonNull T> build() { this.name = this.name != null ? this.name : TopicProcessor.class.getSimpleName(); this.waitStrategy = this.waitStrategy != null ? this.waitStrategy : WaitStrategy.phasedOffLiteLock(200, 100, TimeUnit.MILLISECONDS); ThreadFactory threadFactory = this.executor != null ? null : new EventLoopFactory(name, autoCancel); @@ -220,7 +221,7 @@ public TopicProcessor build() { * Create a new {@link TopicProcessor} {@link Builder} with default properties. * @return new TopicProcessor builder */ - public static Builder builder() { + public static Builder<@NonNull E> builder() { return new Builder<>(); } @@ -231,7 +232,7 @@ public static Builder builder() { * @param Type of processed signals * @return a fresh processor */ - public static TopicProcessor create() { + public static TopicProcessor<@NonNull E> create() { return TopicProcessor.builder().build(); } @@ -245,7 +246,7 @@ public static TopicProcessor create() { * @param Type of processed signals * @return the fresh TopicProcessor instance */ - public static TopicProcessor create(String name, int bufferSize) { + public static TopicProcessor<@NonNull E> create(String name, int bufferSize) { return TopicProcessor.builder().name(name).bufferSize(bufferSize).build(); } @@ -264,7 +265,7 @@ public static TopicProcessor create(String name, int bufferSize) { * @param Type of processed signals * @return a fresh processor */ - public static TopicProcessor share(String name, int bufferSize) { + public static TopicProcessor<@NonNull E> share(String name, int bufferSize) { return TopicProcessor.builder().share(true).name(name).bufferSize(bufferSize).build(); } @@ -280,7 +281,7 @@ public static TopicProcessor share(String name, int bufferSize) { WaitStrategy waitStrategy, boolean shared, boolean autoCancel, - @Nullable final Supplier signalSupplier) { + @Nullable final Supplier<@NonNull E> signalSupplier) { super(bufferSize, threadFactory, executor, requestTaskExecutor, autoCancel, shared, () -> { Slot signal = new Slot<>(); @@ -295,7 +296,7 @@ public static TopicProcessor share(String name, int bufferSize) { } @Override - public void subscribe(final CoreSubscriber actual) { + public void subscribe(final CoreSubscriber actual) { Objects.requireNonNull(actual, "subscribe"); if (!alive()) { @@ -421,9 +422,9 @@ public void run() { * @param pendingRequest holder for the number of pending requests * @param subscriber the output Subscriber instance */ - TopicInner(TopicProcessor processor, + TopicInner(TopicProcessor<@NonNull T> processor, RingBuffer.Sequence pendingRequest, - CoreSubscriber subscriber) { + CoreSubscriber subscriber) { this.processor = processor; this.pendingRequest = pendingRequest; this.subscriber = subscriber; @@ -559,7 +560,7 @@ public Object scanUnsafe(Attr key) { } @Override - public CoreSubscriber actual() { + public CoreSubscriber actual() { return subscriber; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java index 0e5051ad5b..8bb7395b49 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.function.Consumer; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -31,6 +30,8 @@ import reactor.core.Fuseable; import reactor.util.concurrent.Queues; import reactor.util.context.Context; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A Processor implementation that takes a custom queue and allows @@ -52,7 +53,7 @@ public final class UnicastProcessor * @param the relayed type * @return a unicast {@link FluxProcessor} */ - public static UnicastProcessor create() { + public static UnicastProcessor<@NonNull E> create() { return new UnicastProcessor<>(Queues.unbounded().get()); } @@ -64,7 +65,7 @@ public static UnicastProcessor create() { * @param the relayed type * @return a unicast {@link FluxProcessor} */ - public static UnicastProcessor create(Queue queue) { + public static UnicastProcessor<@NonNull E> create(Queue<@NonNull E> queue) { return new UnicastProcessor<>(queue); } @@ -77,7 +78,7 @@ public static UnicastProcessor create(Queue queue) { * @param the relayed type * @return a unicast {@link FluxProcessor} */ - public static UnicastProcessor create(Queue queue, Disposable endcallback) { + public static UnicastProcessor<@NonNull E> create(Queue<@NonNull E> queue, Disposable endcallback) { return new UnicastProcessor<>(queue, endcallback); } @@ -93,8 +94,8 @@ public static UnicastProcessor create(Queue queue, Disposable endcallb * * @return a unicast {@link FluxProcessor} */ - public static UnicastProcessor create(Queue queue, - Consumer onOverflow, + public static UnicastProcessor<@NonNull E> create(Queue<@NonNull E> queue, + Consumer onOverflow, Disposable endcallback) { return new UnicastProcessor<>(queue, onOverflow, endcallback); } @@ -131,20 +132,20 @@ public static UnicastProcessor create(Queue queue, volatile boolean outputFused; - public UnicastProcessor(Queue queue) { + public UnicastProcessor(Queue<@NonNull T> queue) { this.queue = Objects.requireNonNull(queue, "queue"); this.onTerminate = null; this.onOverflow = null; } - public UnicastProcessor(Queue queue, Disposable onTerminate) { + public UnicastProcessor(Queue<@NonNull T> queue, Disposable onTerminate) { this.queue = Objects.requireNonNull(queue, "queue"); this.onTerminate = Objects.requireNonNull(onTerminate, "onTerminate"); this.onOverflow = null; } - public UnicastProcessor(Queue queue, - Consumer onOverflow, + public UnicastProcessor(Queue<@NonNull T> queue, + Consumer onOverflow, Disposable onTerminate) { this.queue = Objects.requireNonNull(queue, "queue"); this.onOverflow = Objects.requireNonNull(onOverflow, "onOverflow"); @@ -163,7 +164,7 @@ void doTerminate() { } } - void drainRegular(Subscriber a) { + void drainRegular(Subscriber a) { int missed = 1; final Queue q = queue; @@ -209,7 +210,7 @@ void drainRegular(Subscriber a) { } } - void drainFused(Subscriber a) { + void drainFused(Subscriber a) { int missed = 1; final Queue q = queue; @@ -271,7 +272,7 @@ void drain() { } } - boolean checkTerminated(boolean d, boolean empty, Subscriber a, Queue q) { + boolean checkTerminated(boolean d, boolean empty, Subscriber a, Queue<@NonNull T> q) { if (cancelled) { q.clear(); actual = null; @@ -365,7 +366,7 @@ public void onComplete() { } @Override - public void subscribe(CoreSubscriber actual) { + public void subscribe(CoreSubscriber actual) { Objects.requireNonNull(actual, "subscribe"); if (once == 0 && ONCE.compareAndSet(this, 0, 1)) { @@ -453,7 +454,7 @@ public Throwable getError() { } @Override - public CoreSubscriber actual() { + public CoreSubscriber actual() { return actual; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/WorkQueueProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/WorkQueueProcessor.java index cc47617254..64076dbf25 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/WorkQueueProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/WorkQueueProcessor.java @@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.locks.LockSupport; import java.util.function.Supplier; -import javax.annotation.Nullable; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -38,6 +37,8 @@ import reactor.util.Loggers; import reactor.util.concurrent.Queues; import reactor.util.concurrent.WaitStrategy; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** ** An implementation of a RingBuffer backed message-passing Processor implementing work-queue distribution with @@ -98,7 +99,7 @@ public final static class Builder { * if {@link #executor(ExecutorService)} is not configured. * @return builder with provided name */ - public Builder name(@Nullable String name) { + public Builder<@NonNull T> name(@Nullable String name) { if (executor != null) throw new IllegalArgumentException("Executor service is configured, name will not be used."); this.name = name; @@ -110,7 +111,7 @@ public Builder name(@Nullable String name) { * @param bufferSize the internal buffer size to hold signals, must be a power of 2 * @return builder with provided buffer size */ - public Builder bufferSize(int bufferSize) { + public Builder<@NonNull T> bufferSize(int bufferSize) { if (!Queues.isPowerOfTwo(bufferSize)) { throw new IllegalArgumentException("bufferSize must be a power of 2 : " + bufferSize); } @@ -129,7 +130,7 @@ public Builder bufferSize(int bufferSize) { * @param waitStrategy A RingBuffer WaitStrategy to use instead of the default smart blocking wait strategy. * @return builder with provided wait strategy */ - public Builder waitStrategy(@Nullable WaitStrategy waitStrategy) { + public Builder<@NonNull T> waitStrategy(@Nullable WaitStrategy waitStrategy) { this.waitStrategy = waitStrategy; return this; } @@ -139,7 +140,7 @@ public Builder waitStrategy(@Nullable WaitStrategy waitStrategy) { * @param autoCancel automatically cancel * @return builder with provided auto-cancel */ - public Builder autoCancel(boolean autoCancel) { + public Builder<@NonNull T> autoCancel(boolean autoCancel) { this.autoCancel = autoCancel; return this; } @@ -151,7 +152,7 @@ public Builder autoCancel(boolean autoCancel) { * @param executor A provided ExecutorService to manage threading infrastructure * @return builder with provided executor */ - public Builder executor(@Nullable ExecutorService executor) { + public Builder<@NonNull T> executor(@Nullable ExecutorService executor) { this.executor = executor; return this; } @@ -162,7 +163,7 @@ public Builder executor(@Nullable ExecutorService executor) { * @param requestTaskExecutor internal request executor * @return builder with provided internal request executor */ - public Builder requestTaskExecutor(@Nullable ExecutorService requestTaskExecutor) { + public Builder<@NonNull T> requestTaskExecutor(@Nullable ExecutorService requestTaskExecutor) { this.requestTaskExecutor = requestTaskExecutor; return this; } @@ -174,7 +175,7 @@ public Builder requestTaskExecutor(@Nullable ExecutorService requestTaskExecu * @param share true to support concurrent onNext calls * @return builder with specified sharing */ - public Builder share(boolean share) { + public Builder<@NonNull T> share(boolean share) { this.share = share; return this; } @@ -184,7 +185,7 @@ public Builder share(boolean share) { * of this builder. * @return a fresh processor */ - public WorkQueueProcessor build() { + public WorkQueueProcessor<@NonNull T> build() { String name = this.name != null ? this.name : WorkQueueProcessor.class.getSimpleName(); WaitStrategy waitStrategy = this.waitStrategy != null ? this.waitStrategy : WaitStrategy.liteBlocking(); ThreadFactory threadFactory = this.executor != null ? null : new EventLoopFactory(name, autoCancel); @@ -205,7 +206,7 @@ public WorkQueueProcessor build() { * Create a new {@link WorkQueueProcessor} {@link Builder} with default properties. * @return new WorkQueueProcessor builder */ - public final static Builder builder() { + public final static Builder<@NonNull T> builder() { return new Builder<>(); } @@ -216,7 +217,7 @@ public final static Builder builder() { * @param Type of processed signals * @return a fresh processor */ - public static WorkQueueProcessor create() { + public static WorkQueueProcessor<@NonNull E> create() { return WorkQueueProcessor.builder().build(); } @@ -230,7 +231,7 @@ public static WorkQueueProcessor create() { * @param Type of processed signals * @return a fresh processor */ - public static WorkQueueProcessor create(String name, int bufferSize) { + public static WorkQueueProcessor<@NonNull E> create(String name, int bufferSize) { return WorkQueueProcessor.builder().name(name).bufferSize(bufferSize).build(); } @@ -246,7 +247,7 @@ public static WorkQueueProcessor create(String name, int bufferSize) { * @param Type of processed signals * @return a fresh processor */ - public static WorkQueueProcessor share(String name, int bufferSize) { + public static WorkQueueProcessor<@NonNull E> share(String name, int bufferSize) { return WorkQueueProcessor.builder().share(true).name(name).bufferSize(bufferSize).build(); } @@ -291,7 +292,7 @@ public static WorkQueueProcessor share(String name, int bufferSize) { } @Override - public void subscribe(final CoreSubscriber actual) { + public void subscribe(final CoreSubscriber actual) { Objects.requireNonNull(actual, "subscribe"); if (!alive()) { @@ -429,8 +430,8 @@ public void run() { * @param subscriber the output Subscriber instance * @param processor the source processor */ - WorkQueueInner(CoreSubscriber subscriber, - WorkQueueProcessor processor) { + WorkQueueInner(CoreSubscriber subscriber, + WorkQueueProcessor<@NonNull T> processor) { this.processor = processor; this.subscriber = subscriber; @@ -655,7 +656,7 @@ boolean replay(final boolean unbounded) { } } - boolean reschedule(@Nullable Slot event) { + boolean reschedule(@Nullable Slot<@NonNull T> event) { if (event != null && event.value != null) { processor.claimedDisposed.add(event.value); @@ -690,7 +691,7 @@ public Object scanUnsafe(Attr key) { } @Override - public CoreSubscriber actual() { + public CoreSubscriber actual() { return subscriber; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/package-info.java b/reactor-core/src/main/java/reactor/core/publisher/package-info.java index 6cc8cc9c42..75079d20e3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/package-info.java +++ b/reactor-core/src/main/java/reactor/core/publisher/package-info.java @@ -47,4 +47,4 @@ @NonNullApi package reactor.core.publisher; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/core/scheduler/ElasticScheduler.java b/reactor-core/src/main/java/reactor/core/scheduler/ElasticScheduler.java index ba05d08fc4..89e14edbc6 100644 --- a/reactor-core/src/main/java/reactor/core/scheduler/ElasticScheduler.java +++ b/reactor-core/src/main/java/reactor/core/scheduler/ElasticScheduler.java @@ -27,10 +27,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Supplier; -import javax.annotation.Nullable; import reactor.core.Disposable; import reactor.core.Disposables; +import reactor.util.annotation.Nullable; /** * Dynamically creates ScheduledExecutorService-based Workers and caches the thread pools, reusing diff --git a/reactor-core/src/main/java/reactor/core/scheduler/SchedulerTask.java b/reactor-core/src/main/java/reactor/core/scheduler/SchedulerTask.java index fd9ab334ea..d82c82b946 100644 --- a/reactor-core/src/main/java/reactor/core/scheduler/SchedulerTask.java +++ b/reactor-core/src/main/java/reactor/core/scheduler/SchedulerTask.java @@ -20,9 +20,9 @@ import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import reactor.core.Disposable; +import reactor.util.annotation.Nullable; final class SchedulerTask implements Runnable, Disposable, Callable { diff --git a/reactor-core/src/main/java/reactor/core/scheduler/WorkerTask.java b/reactor-core/src/main/java/reactor/core/scheduler/WorkerTask.java index eeafd074e0..2ac5c77005 100644 --- a/reactor-core/src/main/java/reactor/core/scheduler/WorkerTask.java +++ b/reactor-core/src/main/java/reactor/core/scheduler/WorkerTask.java @@ -22,9 +22,9 @@ import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; import reactor.core.Disposable; +import reactor.util.annotation.Nullable; /** * A runnable task for {@link Scheduler} Workers that are time-capable (implementing a diff --git a/reactor-core/src/main/java/reactor/core/scheduler/package-info.java b/reactor-core/src/main/java/reactor/core/scheduler/package-info.java index 6c9fc14e1b..5a9c2c6082 100644 --- a/reactor-core/src/main/java/reactor/core/scheduler/package-info.java +++ b/reactor-core/src/main/java/reactor/core/scheduler/package-info.java @@ -23,4 +23,4 @@ @NonNullApi package reactor.core.scheduler; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/util/Logger.java b/reactor-core/src/main/java/reactor/util/Logger.java index 9bf3d0cbcd..100e4c470d 100644 --- a/reactor-core/src/main/java/reactor/util/Logger.java +++ b/reactor-core/src/main/java/reactor/util/Logger.java @@ -15,6 +15,8 @@ */ package reactor.util; +import reactor.util.annotation.Nullable; + /** * Logger interface designed for internal Reactor usage. */ @@ -53,7 +55,7 @@ public interface Logger { * @param format the format string * @param arguments a list of 3 or more arguments */ - void trace(String format, Object... arguments); + void trace(String format, @Nullable Object @Nullable ... arguments); /** * Log an exception (throwable) at the TRACE level with an @@ -91,7 +93,7 @@ public interface Logger { * @param format the format string * @param arguments a list of 3 or more arguments */ - void debug(String format, Object... arguments); + void debug(String format, @Nullable Object @Nullable ... arguments); /** * Log an exception (throwable) at the DEBUG level with an @@ -129,7 +131,7 @@ public interface Logger { * @param format the format string * @param arguments a list of 3 or more arguments */ - void info(String format, Object... arguments); + void info(String format, @Nullable Object @Nullable ... arguments); /** * Log an exception (throwable) at the INFO level with an @@ -167,7 +169,7 @@ public interface Logger { * @param format the format string * @param arguments a list of 3 or more arguments */ - void warn(String format, Object... arguments); + void warn(String format, @Nullable Object @Nullable ... arguments); /** * Log an exception (throwable) at the WARN level with an @@ -205,7 +207,7 @@ public interface Logger { * @param format the format string * @param arguments a list of 3 or more arguments */ - void error(String format, Object... arguments); + void error(String format, @Nullable Object @Nullable ... arguments); /** * Log an exception (throwable) at the ERROR level with an diff --git a/reactor-core/src/main/java/reactor/util/Loggers.java b/reactor-core/src/main/java/reactor/util/Loggers.java index 665745a1a4..362368ba6f 100644 --- a/reactor-core/src/main/java/reactor/util/Loggers.java +++ b/reactor-core/src/main/java/reactor/util/Loggers.java @@ -20,7 +20,8 @@ import java.util.logging.Level; import java.util.regex.Matcher; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; + /** * Expose static methods to get a logger depending on the environment. If SL4J is on the @@ -400,7 +401,7 @@ public void error(String msg, Throwable t) { } @Nullable - private String format(@Nullable String from, @Nullable Object... arguments){ + private String format(@Nullable String from, @Nullable Object @Nullable ... arguments){ if(from != null) { String computed = from; if (arguments != null && arguments.length != 0) { @@ -448,7 +449,7 @@ public String getName() { } @Nullable - private String format(@Nullable String from, @Nullable Object... arguments){ + private String format(@Nullable String from, @Nullable Object @Nullable ... arguments){ if(from != null) { String computed = from; if (arguments != null && arguments.length != 0) { diff --git a/reactor-core/src/main/java/reactor/util/annotation/NonNull.java b/reactor-core/src/main/java/reactor/util/annotation/NonNull.java new file mode 100644 index 0000000000..bc00b6fd1a --- /dev/null +++ b/reactor-core/src/main/java/reactor/util/annotation/NonNull.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2017 the original author or authors. + * + * 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 + * + * http://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.util.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierNickname; + +/** + * A common Reactor annotation (similar to Spring ones) to declare that annotated elements + * cannot be {@code null}. Leverages JSR 305 meta-annotations to indicate nullability in + * Java to common tools with JSR 305 support and used by Kotlin to infer nullability of + * Reactor API. + * + *

Should be used at generic type argument, parameter, return value, and field level. + * Methods overrides should repeat parent {@code @NonNull} annotations unless they behave + * differently. + * + *

Use {@code @NonNullApi} (scope = parameters + return values) to set the default + * behavior to non-nullable in order to avoid annotating your whole codebase with + * {@code @NonNull}. No default restricted to generic type argument is possible + * ({@code ElementType.TYPE_USE} scope is too wide) so each generic type argument + * needs to be annotated with @code @NonNull}. + * + * @author Sebastien Deleuze + * @author Juergen Hoeller + * @since 3.1.0 + * @see NonNullApi + * @see Nullable + */ +@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_USE, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierNickname +public @interface NonNull { +} diff --git a/reactor-core/src/main/java/reactor/util/lang/NonNullApi.java b/reactor-core/src/main/java/reactor/util/annotation/NonNullApi.java similarity index 50% rename from reactor-core/src/main/java/reactor/util/lang/NonNullApi.java rename to reactor-core/src/main/java/reactor/util/annotation/NonNullApi.java index e16726c533..d23ba1ad99 100644 --- a/reactor-core/src/main/java/reactor/util/lang/NonNullApi.java +++ b/reactor-core/src/main/java/reactor/util/annotation/NonNullApi.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2011-2017 Pivotal Software Inc, All Rights Reserved. + * Copyright 2002-2017 the original author or authors. * * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://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, @@ -14,36 +14,43 @@ * limitations under the License. */ -package reactor.util.lang; +package reactor.util.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.annotation.Nonnull; import javax.annotation.meta.TypeQualifierDefault; /** - * Leverage JSR 305 meta-annotations to define that parameters and return values are - * non-nullable by default. + * A common Reactor annotation (similar to Spring one) to declare that parameters and return + * values are to be considered as non-nullable by default for a given package. + * Leverages JSR 305 meta-annotations to indicate nullability in Java to common tools with + * JSR 305 support and used by Kotlin to infer nullability of Reactor API. + * * - * Should be used at package level in association with {@link javax.annotation.Nullable} - * parameters and return values level annotations. + *

Should be used at package level in association with {@link Nullable} + * annotations at parameter and return value level. * - * Present in Spring Framework 5 + *

This annotation does not define nullability of generic type arguments, because + * {@code @TypeQualifierDefault(ElementType.TYPE_USE)} scope would be too broad. + * As a consequence, each API generic type argument should be annotated + * with {@link Nullable} or {@link NonNull} to specify their nullability. * * @author Sebastien Deleuze + * @author Juergen Hoeller * @since 3.1.0 - * @see javax.annotation.Nullable - * @see javax.annotation.Nonnull + + * @see Nullable + * @see NonNull */ -//this is similar to what in done in Spring Framework 5 `org.springframework.lang.NonNullApi` +@Target(ElementType.PACKAGE) +@Retention(RetentionPolicy.RUNTIME) @Documented @Nonnull -@Target({ElementType.PACKAGE, ElementType.TYPE}) @TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) -@Retention(RetentionPolicy.RUNTIME) public @interface NonNullApi { - } diff --git a/reactor-core/src/main/java/reactor/util/annotation/Nullable.java b/reactor-core/src/main/java/reactor/util/annotation/Nullable.java new file mode 100644 index 0000000000..be1ca82527 --- /dev/null +++ b/reactor-core/src/main/java/reactor/util/annotation/Nullable.java @@ -0,0 +1,54 @@ +/* + * Copyright 2002-2017 the original author or authors. + * + * 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 + * + * http://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.util.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +/** + * A common Reactor annotation (similar to Spring ones) to declare that annotated elements + * can be {@code null} under some circumstance. Leverages JSR 305 meta-annotations to + * indicate nullability in Java to common tools with JSR 305 support and used by Kotlin to + * infer nullability of Reactor API. + * + *

Should be used at generic type argument, parameter, return value, and field level. + * Methods overrides should repeat parent {@code @Nullable} annotations unless they behave + * differently. + * + *

Can be used in association with {@code NonNullApi} to override the default + * non-nullable semantic to nullable. + * + * @author Sebastien Deleuze + * @author Juergen Hoeller + * @since 3.1.0 + * @see NonNullApi + * @see NonNull + */ +@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_USE, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull(when = When.MAYBE) +@TypeQualifierNickname +public @interface Nullable { +} diff --git a/reactor-core/src/main/java/reactor/util/annotation/package-info.java b/reactor-core/src/main/java/reactor/util/annotation/package-info.java new file mode 100644 index 0000000000..1d12460e7e --- /dev/null +++ b/reactor-core/src/main/java/reactor/util/annotation/package-info.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2011-2017 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 + * + * http://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. + */ + +/** + * Annotations mainly intended for internal use in order to define nullability + * of Reactor API, used by tooling (IDEA) and Kotlin. + */ +package reactor.util.annotation; + diff --git a/reactor-core/src/main/java/reactor/util/concurrent/Queues.java b/reactor-core/src/main/java/reactor/util/concurrent/Queues.java index 1b76c06ef2..9a50d622f0 100644 --- a/reactor-core/src/main/java/reactor/util/concurrent/Queues.java +++ b/reactor-core/src/main/java/reactor/util/concurrent/Queues.java @@ -24,7 +24,9 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * Queue utilities and suppliers for 1-producer/1-consumer ready queues adapted for @@ -94,7 +96,7 @@ public static int ceilingNextPowerOfTwo(final int x) { * @return an unbounded or bounded {@link Queue} {@link Supplier} */ @SuppressWarnings("unchecked") - public static Supplier> get(int batchSize) { + public static Supplier<@NonNull Queue<@NonNull T>> get(int batchSize) { if (batchSize == Integer.MAX_VALUE) { return SMALL_UNBOUNDED; } @@ -132,7 +134,7 @@ public static boolean isPowerOfTwo(final int x) { * @return a bounded {@link Queue} {@link Supplier} */ @SuppressWarnings("unchecked") - public static Supplier> one() { + public static Supplier<@NonNull Queue<@NonNull T>> one() { return ONE_SUPPLIER; } @@ -142,7 +144,7 @@ public static Supplier> one() { * @return a bounded {@link Queue} {@link Supplier} */ @SuppressWarnings("unchecked") - public static Supplier> small() { + public static Supplier<@NonNull Queue<@NonNull T>> small() { return SMALL_SUPPLIER; } @@ -152,7 +154,7 @@ public static Supplier> small() { * @return an unbounded {@link Queue} {@link Supplier} */ @SuppressWarnings("unchecked") - public static Supplier> unbounded() { + public static Supplier<@NonNull Queue<@NonNull T>> unbounded() { return SMALL_UNBOUNDED; } @@ -164,7 +166,7 @@ public static Supplier> unbounded() { * @return an unbounded {@link Queue} {@link Supplier} */ @SuppressWarnings("unchecked") - public static Supplier> unbounded(int linkSize) { + public static Supplier<@NonNull Queue<@NonNull T>> unbounded(int linkSize) { if (linkSize == XS_BUFFER_SIZE) { return XS_UNBOUNDED; } @@ -180,7 +182,7 @@ else if (linkSize == Integer.MAX_VALUE || linkSize == SMALL_BUFFER_SIZE) { * @return a bounded {@link Queue} {@link Supplier} */ @SuppressWarnings("unchecked") - public static Supplier> xs() { + public static Supplier<@NonNull Queue<@NonNull T>> xs() { return XS_SUPPLIER; } diff --git a/reactor-core/src/main/java/reactor/util/concurrent/SpscArrayQueue.java b/reactor-core/src/main/java/reactor/util/concurrent/SpscArrayQueue.java index 963a15f041..da5c0ec53d 100644 --- a/reactor-core/src/main/java/reactor/util/concurrent/SpscArrayQueue.java +++ b/reactor-core/src/main/java/reactor/util/concurrent/SpscArrayQueue.java @@ -21,7 +21,8 @@ import java.util.Queue; import java.util.concurrent.atomic.*; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; + /** * A bounded, array backed, single-producer single-consumer queue. diff --git a/reactor-core/src/main/java/reactor/util/concurrent/SpscLinkedArrayQueue.java b/reactor-core/src/main/java/reactor/util/concurrent/SpscLinkedArrayQueue.java index b59a675294..596ba2ef78 100644 --- a/reactor-core/src/main/java/reactor/util/concurrent/SpscLinkedArrayQueue.java +++ b/reactor-core/src/main/java/reactor/util/concurrent/SpscLinkedArrayQueue.java @@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.function.BiPredicate; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; + /** * An unbounded, array-backed single-producer, single-consumer queue with a fixed link diff --git a/reactor-core/src/main/java/reactor/util/concurrent/package-info.java b/reactor-core/src/main/java/reactor/util/concurrent/package-info.java index 225530678a..800817eeca 100644 --- a/reactor-core/src/main/java/reactor/util/concurrent/package-info.java +++ b/reactor-core/src/main/java/reactor/util/concurrent/package-info.java @@ -24,4 +24,4 @@ @NonNullApi package reactor.util.concurrent; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/util/context/Context.java b/reactor-core/src/main/java/reactor/util/context/Context.java index 6c2968b515..035821ecc4 100644 --- a/reactor-core/src/main/java/reactor/util/context/Context.java +++ b/reactor-core/src/main/java/reactor/util/context/Context.java @@ -20,7 +20,9 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.stream.Stream; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A key/value store that is propagated between components such as operators via the @@ -249,7 +251,7 @@ default boolean isEmpty() { * * @return a {@link Stream} of key/value pairs held by this context */ - Stream> stream(); + Stream> stream(); /** * Create a new {@link Context} by merging the content of this context and a given diff --git a/reactor-core/src/main/java/reactor/util/context/ContextN.java b/reactor-core/src/main/java/reactor/util/context/ContextN.java index ba4c055cb0..eda171c163 100644 --- a/reactor-core/src/main/java/reactor/util/context/ContextN.java +++ b/reactor-core/src/main/java/reactor/util/context/ContextN.java @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; @@ -25,7 +24,8 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nullable; + +import reactor.util.annotation.Nullable; @SuppressWarnings("unchecked") final class ContextN extends HashMap diff --git a/reactor-core/src/main/java/reactor/util/context/package-info.java b/reactor-core/src/main/java/reactor/util/context/package-info.java index 8381a60289..8305c42f43 100644 --- a/reactor-core/src/main/java/reactor/util/context/package-info.java +++ b/reactor-core/src/main/java/reactor/util/context/package-info.java @@ -20,4 +20,4 @@ @NonNullApi package reactor.util.context; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple2.java b/reactor-core/src/main/java/reactor/util/function/Tuple2.java index 73d0fca0ae..034c7a68f4 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple2.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple2.java @@ -23,7 +23,9 @@ import java.util.List; import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds two non-null values. @@ -88,7 +90,7 @@ public Object get(int index) { * * @return A new Object list. */ - public List toList() { + public List<@NonNull Object> toList() { return Arrays.asList(toArray()); } @@ -97,7 +99,7 @@ public List toList() { * * @return A new Object array. */ - public Object[] toArray() { + public Object @NonNull[] toArray() { return new Object[]{t1, t2}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple3.java b/reactor-core/src/main/java/reactor/util/function/Tuple3.java index 1d6e4b26dd..aba805e6b4 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple3.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple3.java @@ -18,7 +18,9 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds three non-null values. @@ -65,7 +67,7 @@ public Object get(int index) { } @Override - public Object[] toArray() { + public Object @NonNull [] toArray() { return new Object[]{t1, t2, t3}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple4.java b/reactor-core/src/main/java/reactor/util/function/Tuple4.java index 4b48c045a6..ff6d52557a 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple4.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple4.java @@ -18,7 +18,9 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds four non-null values @@ -68,7 +70,7 @@ public Object get(int index) { } @Override - public Object[] toArray() { + public Object @NonNull [] toArray() { return new Object[]{t1, t2, t3, t4}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple5.java b/reactor-core/src/main/java/reactor/util/function/Tuple5.java index ee1c740676..ed670f7dd7 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple5.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple5.java @@ -18,7 +18,9 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds five non-null values @@ -71,7 +73,7 @@ public Object get(int index) { } @Override - public Object[] toArray() { + public Object @NonNull [] toArray() { return new Object[]{t1, t2, t3, t4, t5}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple6.java b/reactor-core/src/main/java/reactor/util/function/Tuple6.java index f40462681a..7ee5437a0c 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple6.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple6.java @@ -18,7 +18,9 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds six values @@ -74,7 +76,7 @@ public Object get(int index) { } @Override - public Object[] toArray() { + public Object @NonNull [] toArray() { return new Object[]{t1, t2, t3, t4, t5, t6}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple7.java b/reactor-core/src/main/java/reactor/util/function/Tuple7.java index ef8c2a3504..88e1498512 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple7.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple7.java @@ -18,7 +18,9 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds seven non-null values @@ -77,7 +79,7 @@ public Object get(int index) { } @Override - public Object[] toArray() { + public Object @NonNull [] toArray() { return new Object[]{t1, t2, t3, t4, t5, t6, t7}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple8.java b/reactor-core/src/main/java/reactor/util/function/Tuple8.java index d1a54e3990..940a6bbb2f 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple8.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple8.java @@ -18,7 +18,9 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A tuple that holds eight values @@ -81,7 +83,7 @@ public Object get(int index) { } @Override - public Object[] toArray() { + public Object @NonNull [] toArray() { return new Object[]{t1, t2, t3, t4, t5, t6, t7, t8}; } diff --git a/reactor-core/src/main/java/reactor/util/function/Tuples.java b/reactor-core/src/main/java/reactor/util/function/Tuples.java index 5f7bf2cb4f..a0c92261bd 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuples.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuples.java @@ -19,6 +19,8 @@ import java.util.Collection; import java.util.function.Function; +import reactor.util.annotation.NonNull; + /** * A {@literal Tuples} is an immutable {@link Collection} of objects, each of which can be of an arbitrary type. * @@ -36,7 +38,7 @@ public abstract class Tuples implements Function { * @return The new {@link Tuple2}. * @throws IllegalArgumentException if the array is not of length 1-8 */ - public static Tuple2 fromArray(Object[] list) { + public static Tuple2 fromArray(Object @NonNull [] list) { //noinspection ConstantConditions if (list == null || list.length < 2) { throw new IllegalArgumentException("null or too small array, need between 2 and 8 values"); @@ -475,7 +477,7 @@ public Tuple2 apply(Object o) { * @return a {@link StringBuilder} initialized with the string representation of the * values in the Tuple. */ - static StringBuilder tupleStringRepresentation(Object... values) { + static StringBuilder tupleStringRepresentation(Object @NonNull ... values) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.length; i++) { Object t = values[i]; diff --git a/reactor-core/src/main/java/reactor/util/function/package-info.java b/reactor-core/src/main/java/reactor/util/function/package-info.java index 88aa4614c7..4c41621d34 100644 --- a/reactor-core/src/main/java/reactor/util/function/package-info.java +++ b/reactor-core/src/main/java/reactor/util/function/package-info.java @@ -20,4 +20,4 @@ @NonNullApi package reactor.util.function; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/util/package-info.java b/reactor-core/src/main/java/reactor/util/package-info.java index 13b85fb99a..5d3c747ea8 100644 --- a/reactor-core/src/main/java/reactor/util/package-info.java +++ b/reactor-core/src/main/java/reactor/util/package-info.java @@ -20,5 +20,4 @@ @NonNullApi package reactor.util; -import reactor.util.lang.NonNullApi; -import javax.annotation.Nullable; \ No newline at end of file +import reactor.util.annotation.NonNullApi; diff --git a/reactor-core/src/test/java/reactor/guide/GuideTests.java b/reactor-core/src/test/java/reactor/guide/GuideTests.java index a8215d303e..abbe79fb23 100644 --- a/reactor-core/src/test/java/reactor/guide/GuideTests.java +++ b/reactor-core/src/test/java/reactor/guide/GuideTests.java @@ -59,7 +59,6 @@ import reactor.util.context.Context; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; -import reactor.util.lang.NonNullApi; import static org.assertj.core.api.Assertions.assertThat; @@ -69,7 +68,6 @@ * @author Stephane Maldini * @author Simon Baslé */ -@NonNullApi public class GuideTests { @Test @SuppressWarnings("unchecked") @@ -987,7 +985,7 @@ private void printAndAssert(Throwable t, boolean checkForAssemblySuppressed) { assertThat(withSuppressed.getSuppressed()).hasSize(1); assertThat(withSuppressed.getSuppressed()[0]) .hasMessageStartingWith("\nAssembly trace from producer [reactor.core.publisher.MonoSingle] :") - .hasMessageEndingWith("Flux.single(GuideTests.java:951)\n"); + .hasMessageEndingWith("Flux.single(GuideTests.java:949)\n"); }); } } diff --git a/reactor-test/src/main/java/reactor/test/DefaultStepVerifierBuilder.java b/reactor-test/src/main/java/reactor/test/DefaultStepVerifierBuilder.java index 9bce9e01fd..aa1f3394c1 100644 --- a/reactor-test/src/main/java/reactor/test/DefaultStepVerifierBuilder.java +++ b/reactor-test/src/main/java/reactor/test/DefaultStepVerifierBuilder.java @@ -40,7 +40,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nullable; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -56,6 +55,7 @@ import reactor.util.Loggers; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import reactor.util.annotation.Nullable; /** * Default implementation of {@link StepVerifier.Step} and diff --git a/reactor-test/src/main/java/reactor/test/StepVerifier.java b/reactor-test/src/main/java/reactor/test/StepVerifier.java index 590ad38dac..e49f59df2b 100644 --- a/reactor-test/src/main/java/reactor/test/StepVerifier.java +++ b/reactor-test/src/main/java/reactor/test/StepVerifier.java @@ -35,6 +35,7 @@ import reactor.core.scheduler.Schedulers; import reactor.test.scheduler.VirtualTimeScheduler; import reactor.util.function.Tuple2; +import reactor.util.annotation.NonNull; /** * A {@link StepVerifier} provides a declarative way of creating a verifiable script for @@ -670,7 +671,7 @@ default Step assertNext(Consumer assertionConsumer) { * * @see Subscriber#onNext(Object) */ - Step expectNext(T... ts); + Step expectNext(T @NonNull ... ts); /** * Expect to received {@code count} elements, starting from the previous @@ -953,14 +954,14 @@ interface Assertions { * Assert that the tested publisher has dropped at least all of the provided * elements to the {@link Hooks#onNextDropped(Consumer)} hook, in any order. */ - Assertions hasDropped(Object... values); + Assertions hasDropped(Object @NonNull ... values); /** * Assert that the tested publisher has dropped all of the provided elements to * the {@link Hooks#onNextDropped(Consumer)} hook, in any order, and that no * other elements were dropped. */ - Assertions hasDroppedExactly(Object... values); + Assertions hasDroppedExactly(Object @NonNull ... values); /** * Assert that the tested publisher has dropped at least one error to the diff --git a/reactor-test/src/main/java/reactor/test/StepVerifierOptions.java b/reactor-test/src/main/java/reactor/test/StepVerifierOptions.java index 1dde2fc100..dd99c5dcd8 100644 --- a/reactor-test/src/main/java/reactor/test/StepVerifierOptions.java +++ b/reactor-test/src/main/java/reactor/test/StepVerifierOptions.java @@ -18,6 +18,8 @@ import java.util.function.Supplier; import reactor.test.scheduler.VirtualTimeScheduler; +import reactor.util.annotation.NonNull; + import javax.annotation.Nullable; /** @@ -89,7 +91,7 @@ public long getInitialRequest() { * @param vtsLookup the supplier of {@link VirtualTimeScheduler} to use. * @return this instance, to continue setting the options. */ - public StepVerifierOptions virtualTimeSchedulerSupplier(Supplier vtsLookup) { + public StepVerifierOptions virtualTimeSchedulerSupplier(Supplier vtsLookup) { this.vtsLookup = vtsLookup; return this; } @@ -100,7 +102,7 @@ public StepVerifierOptions virtualTimeSchedulerSupplier(Supplier getVirtualTimeSchedulerSupplier() { + public Supplier getVirtualTimeSchedulerSupplier() { return vtsLookup; } } diff --git a/reactor-test/src/main/java/reactor/test/package-info.java b/reactor-test/src/main/java/reactor/test/package-info.java index 2d90302a6e..adfea4a0de 100644 --- a/reactor-test/src/main/java/reactor/test/package-info.java +++ b/reactor-test/src/main/java/reactor/test/package-info.java @@ -20,4 +20,4 @@ @NonNullApi package reactor.test; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-test/src/main/java/reactor/test/publisher/DefaultTestPublisher.java b/reactor-test/src/main/java/reactor/test/publisher/DefaultTestPublisher.java index bb218edaef..48406e0d06 100644 --- a/reactor-test/src/main/java/reactor/test/publisher/DefaultTestPublisher.java +++ b/reactor-test/src/main/java/reactor/test/publisher/DefaultTestPublisher.java @@ -28,7 +28,7 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.Operators; -import javax.annotation.Nullable; +import reactor.util.annotation.Nullable; /** * A default implementation of a {@link TestPublisher}. diff --git a/reactor-test/src/main/java/reactor/test/publisher/TestPublisher.java b/reactor-test/src/main/java/reactor/test/publisher/TestPublisher.java index e6f7d06d90..2e02d87c40 100644 --- a/reactor-test/src/main/java/reactor/test/publisher/TestPublisher.java +++ b/reactor-test/src/main/java/reactor/test/publisher/TestPublisher.java @@ -21,7 +21,8 @@ import org.reactivestreams.Subscriber; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import javax.annotation.Nullable; +import reactor.util.annotation.NonNull; +import reactor.util.annotation.Nullable; /** * A {@link Publisher} that you can directly manipulate, triggering @@ -46,7 +47,7 @@ public abstract class TestPublisher implements Publisher, PublisherProbe the type of the publisher * @return the new {@link TestPublisher} */ - public static TestPublisher create() { + public static TestPublisher<@NonNull T> create() { return new DefaultTestPublisher<>(); } @@ -59,19 +60,19 @@ public static TestPublisher create() { * @param the type of the publisher * @return the new noncompliant {@link TestPublisher} */ - public static TestPublisher createNoncompliant(Violation first, Violation... rest) { + public static TestPublisher<@Nullable T> createNoncompliant(Violation first, Violation @Nullable ... rest) { return new DefaultTestPublisher<>(first, rest); } /** * Convenience method to wrap this {@link TestPublisher} to a {@link Flux}. */ - public abstract Flux flux(); + public abstract Flux<@NonNull T> flux(); /** * Convenience method to wrap this {@link TestPublisher} to a {@link Mono}. */ - public abstract Mono mono(); + public abstract Mono<@NonNull T> mono(); /** * Assert that the current minimum request of all this publisher's subscribers @@ -80,14 +81,14 @@ public static TestPublisher createNoncompliant(Violation first, Violation * @param n the expected minimum request * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertMinRequested(long n); + public abstract TestPublisher<@Nullable T> assertMinRequested(long n); /** * Asserts that this publisher has subscribers. * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertSubscribers(); + public abstract TestPublisher<@Nullable T> assertSubscribers(); /** * Asserts that this publisher has exactly n subscribers. @@ -95,21 +96,21 @@ public static TestPublisher createNoncompliant(Violation first, Violation * @param n the expected number of subscribers * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertSubscribers(int n); + public abstract TestPublisher<@Nullable T> assertSubscribers(int n); /** * Asserts that this publisher has no subscribers. * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertNoSubscribers(); + public abstract TestPublisher<@Nullable T> assertNoSubscribers(); /** * Asserts that this publisher has had at least one subscriber that has been cancelled. * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertCancelled(); + public abstract TestPublisher<@Nullable T> assertCancelled(); /** * Asserts that this publisher has had at least n subscribers that have been cancelled. @@ -117,14 +118,14 @@ public static TestPublisher createNoncompliant(Violation first, Violation * @param n the expected number of subscribers to have been cancelled. * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertCancelled(int n); + public abstract TestPublisher<@Nullable T> assertCancelled(int n); /** * Asserts that this publisher has had no cancelled subscribers. * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertNotCancelled(); + public abstract TestPublisher<@Nullable T> assertNotCancelled(); /** * Asserts that this publisher has had subscriber that saw request overflow, @@ -133,7 +134,7 @@ public static TestPublisher createNoncompliant(Violation first, Violation * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertRequestOverflow(); + public abstract TestPublisher<@Nullable T> assertRequestOverflow(); /** * Asserts that this publisher has had no subscriber with request overflow. @@ -142,7 +143,7 @@ public static TestPublisher createNoncompliant(Violation first, Violation * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher assertNoRequestOverflow(); + public abstract TestPublisher<@Nullable T> assertNoRequestOverflow(); /** * Send 1 {@link Subscriber#onNext(Object) onNext} signal to the subscribers. @@ -150,7 +151,7 @@ public static TestPublisher createNoncompliant(Violation first, Violation * @param value the item to emit (can be null if the relevant {@link Violation} is push) * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher next(@Nullable T value); + public abstract TestPublisher<@Nullable T> next(@Nullable T value); /** * Triggers an {@link Subscriber#onError(Throwable) error} signal to the subscribers. @@ -158,14 +159,14 @@ public static TestPublisher createNoncompliant(Violation first, Violation * @param t the {@link Throwable} to trigger * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher error(Throwable t); + public abstract TestPublisher<@Nullable T> error(Throwable t); /** * Triggers {@link Subscriber#onComplete() completion} of this publisher. * * @return this {@link TestPublisher} for chaining. */ - public abstract TestPublisher complete(); + public abstract TestPublisher<@Nullable T> complete(); /** * Send 1-n {@link Subscriber#onNext(Object) onNext} signals to the subscribers. @@ -176,7 +177,7 @@ public static TestPublisher createNoncompliant(Violation first, Violation * @see #next(Object) next */ @SafeVarargs - public final TestPublisher next(@Nullable T first, T... rest) { + public final TestPublisher<@Nullable T> next(@Nullable T first, T @Nullable ... rest) { Objects.requireNonNull(rest, "rest array is null, please cast to T if null T required"); next(first); for (T t : rest) { @@ -194,7 +195,7 @@ public final TestPublisher next(@Nullable T first, T... rest) { * @see #complete() complete */ @SafeVarargs - public final TestPublisher emit(T... values) { + public final TestPublisher<@Nullable T> emit(T @Nullable ... values) { Objects.requireNonNull(values, "values array is null, please cast to T if null T required"); for (T t : values) { next(t); diff --git a/reactor-test/src/main/java/reactor/test/publisher/package-info.java b/reactor-test/src/main/java/reactor/test/publisher/package-info.java index 177a3c8f99..f1713ba898 100644 --- a/reactor-test/src/main/java/reactor/test/publisher/package-info.java +++ b/reactor-test/src/main/java/reactor/test/publisher/package-info.java @@ -21,4 +21,4 @@ @NonNullApi package reactor.test.publisher; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/reactor-test/src/main/java/reactor/test/scheduler/VirtualTimeScheduler.java b/reactor-test/src/main/java/reactor/test/scheduler/VirtualTimeScheduler.java index a785de51a0..d64f0b93d4 100644 --- a/reactor-test/src/main/java/reactor/test/scheduler/VirtualTimeScheduler.java +++ b/reactor-test/src/main/java/reactor/test/scheduler/VirtualTimeScheduler.java @@ -33,6 +33,7 @@ import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Schedulers; import reactor.util.concurrent.Queues; +import reactor.util.annotation.NonNull; /** * A {@link Scheduler} that uses a virtual clock, allowing to manipulate time @@ -108,7 +109,7 @@ public static VirtualTimeScheduler set(VirtualTimeScheduler scheduler) { * @param schedulerSupplier the supplier executed to obtain a fresh {@link VirtualTimeScheduler} * @return the scheduler that is actually used after the operation. */ - static VirtualTimeScheduler enable(Supplier schedulerSupplier) { + static VirtualTimeScheduler enable(Supplier<@NonNull VirtualTimeScheduler> schedulerSupplier) { return enable(schedulerSupplier, false); } @@ -121,7 +122,7 @@ static VirtualTimeScheduler enable(Supplier schedulerSuppl * @param exact whether or not to force the use of the supplier, even if there's a matching scheduler * @return the scheduler that is actually used after the operation. */ - static VirtualTimeScheduler enable(Supplier + static VirtualTimeScheduler enable(Supplier<@NonNull VirtualTimeScheduler> schedulerSupplier, boolean exact) { for (; ; ) { VirtualTimeScheduler s = CURRENT.get(); @@ -469,7 +470,7 @@ public void dispose() { static final Disposable CANCELLED = Disposables.disposed(); static final Disposable EMPTY = Disposables.never(); - static boolean replace(AtomicReference ref, @Nullable Disposable c) { + static boolean replace(AtomicReference<@NonNull Disposable> ref, @Nullable Disposable c) { for (; ; ) { Disposable current = ref.get(); if (current == CANCELLED) { diff --git a/reactor-test/src/main/java/reactor/test/scheduler/package-info.java b/reactor-test/src/main/java/reactor/test/scheduler/package-info.java index 9ae25f8e75..7b5c72fa5a 100644 --- a/reactor-test/src/main/java/reactor/test/scheduler/package-info.java +++ b/reactor-test/src/main/java/reactor/test/scheduler/package-info.java @@ -21,4 +21,4 @@ @NonNullApi package reactor.test.scheduler; -import reactor.util.lang.NonNullApi; \ No newline at end of file +import reactor.util.annotation.NonNullApi; \ No newline at end of file diff --git a/src/docs/asciidoc/advancedFeatures.adoc b/src/docs/asciidoc/advancedFeatures.adoc index 7b88bb275b..cb7780358d 100644 --- a/src/docs/asciidoc/advancedFeatures.adoc +++ b/src/docs/asciidoc/advancedFeatures.adoc @@ -784,4 +784,55 @@ public void contextForLibraryReactivePut() { .expectNext("PUT sent to www.example.com with header X-Correlation-ID = 2-j3r9afaf92j-afkaf") .verifyComplete(); } ----- \ No newline at end of file +---- + +[[null-safety]] +== Null-safety + +Although Java does not allow to express null-safety with its type system, Reactor +now provides annotations to declare nullability of APIs, similar to those provided by +Spring Framework 5. + +Reactor leverages itself these annotations, but they can also be used in any Reactor based +Java project to declare null-safe APIs. Nullability of types used inside method bodies +is outside of the scope of this feature. + +These annotations are meta-annotated with https://jcp.org/en/jsr/detail?id=305[JSR 305] +annotations (a dormant JSR but supported by tools like IntelliJ IDEA) to provide useful +warnings to Java developers related to null-safety in order to avoid `NullPointerException` +at runtime. JSR 305 meta-annotations allows tooling vendors to provide null-safety support +in a generic way, without having to hard-code support for Reactor annotations. + +[NOTE] +==== +It is not necessary nor recommanded to have JSR 305 dependency in user project classpath. +==== + +They are also used by Kotlin which supports natively +https://kotlinlang.org/docs/reference/null-safety.html[null-safety]. By default, types from +Java APIs used in Kotlin are recognized as +https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types[platform types] +for which null-checks are relaxed. +https://github.com/Kotlin/KEEP/blob/jsr-305/proposals/jsr-305-custom-nullability-qualifiers.md[Kotlin support for JSR 305 annotations] ++ Reactor nullability annotations provide null-safety for the whole Reactor API to Kotlin developers, +with the advantage of dealing with `null` related issues at compile time rather than bumping into the famous +`NullPointerException` at runtime. + +The following annotations are provided in the `reactor.util.annotation` package: + + * https://projectreactor.io/docs/core/release/api/reactor/util/annotation/NonNull.html[`@NonNull`] annotation where specific parameter, + return value, generic type argument, varargs element, array element or field cannot be `null` + (not needed on parameter and return value where `@NonNullApi` and `@NonNullFields` applies) . + * https://projectreactor.io/docs/core/release/api/reactor/util/annotation/Nullable.html[`@Nullable`] annotation where specific + parameter, return value, generic type argument, varargs element, array element or field + can be `null`. + * https://projectreactor.io/docs/core/release/api/reactor/util/annotation/NonNullApi.html[`@NonNullApi`] annotation at package level + declares non-null as the default behavior for parameters and return values. + +[NOTE] +==== +Generic type arguments, varargs and array elements are out of the scope of `@NonNullApi`, +because `@TypeQualifierDefault(ElementType.TYPE_USE)` would apply to +a lot of other use cases. As a consequence, nullability for such elements need to be specified +explicitly with `@NonNull` and `@Nullable`. +==== \ No newline at end of file diff --git a/src/docs/asciidoc/kotlin.adoc b/src/docs/asciidoc/kotlin.adoc index 447e5a4726..a3bea7eb3a 100644 --- a/src/docs/asciidoc/kotlin.adoc +++ b/src/docs/asciidoc/kotlin.adoc @@ -1,7 +1,7 @@ [[kotlin]] = Kotlin support -[[introduction]] +[[kotlin-introduction]] == Introduction https://kotlinlang.org[Kotlin] is a statically-typed language targeting the JVM (and other platforms) @@ -11,7 +11,7 @@ existing libraries written in Java. Reactor 3.1 introduces first-class support for Kotlin which is described in this section. -[[requirements]] +[[kotlin-requirements]] == Requirements == Kotlin supports Kotlin 1.1+ and requires @@ -19,7 +19,7 @@ https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-stdlib[`kotlin (or one of its https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-stdlib-jre7[`kotlin-stdlib-jre7`] / https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-stdlib-jre8[`kotlin-stdlib-jre8`] variants). -[[extensions]] +[[kotlin-extensions]] == Extensions Thanks to its great https://kotlinlang.org/docs/reference/java-interop.html[Java interoperability] @@ -60,7 +60,7 @@ You can see bellow a quick comparison of Reactor with Java versus Reactor with K https://projectreactor.io/docs/core/release/kdoc-api/[Reactor KDoc API] lists and documents all the Kotlin extensions available. -[[null-safety]] +[[kotlin-null-safety]] == Null-safety One of Kotlin's key features is https://kotlinlang.org/docs/reference/null-safety.html[null-safety]