-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.x: Fix Generics T[] in Zip & CombineLatest #4525
Changes from all commits
a755ef4
94f4503
b8e5108
39a9e31
4a972f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,11 @@ public static int bufferSize() { | |
* Combines a collection of source Publishers by emitting an item that aggregates the latest values of each of | ||
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
* <dd>The returned {@code Publisher} honors backpressure from downstream. The source {@code Publisher}s | ||
|
@@ -163,14 +168,19 @@ public static int bufferSize() { | |
*/ | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, Function<? super T[], ? extends R> combiner) { | ||
public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, Function<? super Object[], ? extends R> combiner) { | ||
return combineLatest(sources, combiner, bufferSize()); | ||
} | ||
|
||
/** | ||
* Combines a collection of source Publishers by emitting an item that aggregates the latest values of each of | ||
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
* <dd>The returned {@code Publisher} honors backpressure from downstream. The source {@code Publisher}s | ||
|
@@ -194,14 +204,19 @@ public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, | |
*/ | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatest(Function<? super T[], ? extends R> combiner, Publisher<? extends T>... sources) { | ||
public static <T, R> Flowable<R> combineLatest(Function<? super Object[], ? extends R> combiner, Publisher<? extends T>... sources) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one does not seem necessary to be honest. It just has switched arguments with the one above. Or do I oversee anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and other overloads of operators let's you use varargs to specify any number of sources at the expense that varargs has to be the last argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ups right didn't see those little dots there too many overloads ... |
||
return combineLatest(sources, combiner, bufferSize()); | ||
} | ||
|
||
/** | ||
* Combines a collection of source Publishers by emitting an item that aggregates the latest values of each of | ||
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
* <dd>The returned {@code Publisher} honors backpressure from downstream. The source {@code Publisher}s | ||
|
@@ -227,7 +242,7 @@ public static <T, R> Flowable<R> combineLatest(Function<? super T[], ? extends R | |
*/ | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, Function<? super T[], ? extends R> combiner, int bufferSize) { | ||
public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, Function<? super Object[], ? extends R> combiner, int bufferSize) { | ||
ObjectHelper.requireNonNull(sources, "sources is null"); | ||
if (sources.length == 0) { | ||
return empty(); | ||
|
@@ -241,6 +256,11 @@ public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, | |
* Combines a collection of source Publishers by emitting an item that aggregates the latest values of each of | ||
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
* <dd>The returned {@code Publisher} honors backpressure from downstream. The source {@code Publisher}s | ||
|
@@ -265,14 +285,19 @@ public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources, | |
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatest(Iterable<? extends Publisher<? extends T>> sources, | ||
Function<? super T[], ? extends R> combiner) { | ||
Function<? super Object[], ? extends R> combiner) { | ||
return combineLatest(sources, combiner, bufferSize()); | ||
} | ||
|
||
/** | ||
* Combines a collection of source Publishers by emitting an item that aggregates the latest values of each of | ||
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
* <dd>The returned {@code Publisher} honors backpressure from downstream. The source {@code Publisher}s | ||
|
@@ -299,7 +324,7 @@ public static <T, R> Flowable<R> combineLatest(Iterable<? extends Publisher<? ex | |
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatest(Iterable<? extends Publisher<? extends T>> sources, | ||
Function<? super T[], ? extends R> combiner, int bufferSize) { | ||
Function<? super Object[], ? extends R> combiner, int bufferSize) { | ||
ObjectHelper.requireNonNull(sources, "sources is null"); | ||
ObjectHelper.requireNonNull(combiner, "combiner is null"); | ||
ObjectHelper.verifyPositive(bufferSize, "bufferSize"); | ||
|
@@ -310,6 +335,11 @@ public static <T, R> Flowable<R> combineLatest(Iterable<? extends Publisher<? ex | |
* Combines a collection of source Publishers by emitting an item that aggregates the latest values of each of | ||
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
* <dd>The returned {@code Publisher} honors backpressure from downstream. The source {@code Publisher}s | ||
|
@@ -334,7 +364,7 @@ public static <T, R> Flowable<R> combineLatest(Iterable<? extends Publisher<? ex | |
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[] sources, | ||
Function<? super T[], ? extends R> combiner) { | ||
Function<? super Object[], ? extends R> combiner) { | ||
return combineLatestDelayError(sources, combiner, bufferSize()); | ||
} | ||
|
||
|
@@ -343,6 +373,10 @@ public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[ | |
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function and delays any error from the sources until | ||
* all source Publishers terminate. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
|
@@ -367,7 +401,7 @@ public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[ | |
*/ | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatestDelayError(Function<? super T[], ? extends R> combiner, | ||
public static <T, R> Flowable<R> combineLatestDelayError(Function<? super Object[], ? extends R> combiner, | ||
Publisher<? extends T>... sources) { | ||
return combineLatestDelayError(sources, combiner, bufferSize()); | ||
} | ||
|
@@ -377,6 +411,10 @@ public static <T, R> Flowable<R> combineLatestDelayError(Function<? super T[], ? | |
* the source ObservableSources each time an item is received from any of the source Publisher, where this | ||
* aggregation is defined by a specified function and delays any error from the sources until | ||
* all source Publishers terminate. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Scheduler:</b></dt> | ||
|
@@ -398,7 +436,7 @@ public static <T, R> Flowable<R> combineLatestDelayError(Function<? super T[], ? | |
* @see <a href="http://reactivex.io/documentation/operators/combinelatest.html">ReactiveX operators documentation: CombineLatest</a> | ||
*/ | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
public static <T, R> Flowable<R> combineLatestDelayError(Function<? super T[], ? extends R> combiner, | ||
public static <T, R> Flowable<R> combineLatestDelayError(Function<? super Object[], ? extends R> combiner, | ||
int bufferSize, Publisher<? extends T>... sources) { | ||
return combineLatestDelayError(sources, combiner, bufferSize); | ||
} | ||
|
@@ -408,6 +446,10 @@ public static <T, R> Flowable<R> combineLatestDelayError(Function<? super T[], ? | |
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function and delays any error from the sources until | ||
* all source Publishers terminate. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
|
@@ -435,7 +477,7 @@ public static <T, R> Flowable<R> combineLatestDelayError(Function<? super T[], ? | |
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[] sources, | ||
Function<? super T[], ? extends R> combiner, int bufferSize) { | ||
Function<? super Object[], ? extends R> combiner, int bufferSize) { | ||
ObjectHelper.requireNonNull(sources, "sources is null"); | ||
ObjectHelper.requireNonNull(combiner, "combiner is null"); | ||
ObjectHelper.verifyPositive(bufferSize, "bufferSize"); | ||
|
@@ -450,6 +492,10 @@ public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[ | |
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function and delays any error from the sources until | ||
* all source Publishers terminate. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
|
@@ -475,7 +521,7 @@ public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[ | |
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatestDelayError(Iterable<? extends Publisher<? extends T>> sources, | ||
Function<? super T[], ? extends R> combiner) { | ||
Function<? super Object[], ? extends R> combiner) { | ||
return combineLatestDelayError(sources, combiner, bufferSize()); | ||
} | ||
|
||
|
@@ -484,6 +530,10 @@ public static <T, R> Flowable<R> combineLatestDelayError(Iterable<? extends Publ | |
* the source Publishers each time an item is received from any of the source Publishers, where this | ||
* aggregation is defined by a specified function and delays any error from the sources until | ||
* all source Publishers terminate. | ||
* <p> | ||
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the | ||
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a | ||
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}. | ||
* | ||
* <dl> | ||
* <dt><b>Backpressure:</b></dt> | ||
|
@@ -511,7 +561,7 @@ public static <T, R> Flowable<R> combineLatestDelayError(Iterable<? extends Publ | |
@SchedulerSupport(SchedulerSupport.NONE) | ||
@BackpressureSupport(BackpressureKind.FULL) | ||
public static <T, R> Flowable<R> combineLatestDelayError(Iterable<? extends Publisher<? extends T>> sources, | ||
Function<? super T[], ? extends R> combiner, int bufferSize) { | ||
Function<? super Object[], ? extends R> combiner, int bufferSize) { | ||
ObjectHelper.requireNonNull(sources, "sources is null"); | ||
ObjectHelper.requireNonNull(combiner, "combiner is null"); | ||
ObjectHelper.verifyPositive(bufferSize, "bufferSize"); | ||
|
@@ -14955,4 +15005,4 @@ public final TestSubscriber<T> test(long initialRequest, boolean cancel) { // No | |
return ts; | ||
} | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth adding a sentence to the javadocs since people tend to ask why this isn't
? super T[]
If you feel so, you could add these two sentences after the first sentence of all the affected methods and before the marble diagram (as people forget to scroll down below the diagram).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do