Skip to content

Commit 60e43f9

Browse files
remove 'wrap' functionality
We no longer need this as we've merged the interface and abstract classes together and don't need to ensure we have the abstract class.
1 parent 0bf4668 commit 60e43f9

File tree

1 file changed

+31
-57
lines changed

1 file changed

+31
-57
lines changed

rxjava-core/src/main/java/org/rx/reactive/Observable.java

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public Subscription subscribe(Observer<T> observer) {
304304
* @return a Observable that, when a Observer subscribes to it, will execute the given function
305305
*/
306306
public static <T> Observable<T> create(Func1<Subscription, Observer<T>> func) {
307-
return wrap(OperationToObservableFunction.toObservableFunction(func));
307+
return OperationToObservableFunction.toObservableFunction(func);
308308
}
309309

310310
/**
@@ -367,7 +367,7 @@ public static <T> Observable<T> empty() {
367367
* @return a Observable object that calls <code>onError</code> when a Observer subscribes
368368
*/
369369
public static <T> Observable<T> error(Exception exception) {
370-
return wrap(new ThrowObservable<T>(exception));
370+
return new ThrowObservable<T>(exception);
371371
}
372372

373373
/**
@@ -455,7 +455,7 @@ public static <T> Observable<T> just(T value) {
455455
* by the source Observable
456456
*/
457457
public static <T> Observable<T> last(final Observable<T> that) {
458-
return wrap(OperationLast.last(that));
458+
return OperationLast.last(that);
459459
}
460460

461461
/**
@@ -477,7 +477,7 @@ public static <T> Observable<T> last(final Observable<T> that) {
477477
* in the sequence emitted by the source Observable
478478
*/
479479
public static <T, R> Observable<R> map(Observable<T> sequence, Func1<R, T> func) {
480-
return wrap(OperationMap.map(sequence, func));
480+
return OperationMap.map(sequence, func);
481481
}
482482

483483
/**
@@ -532,7 +532,7 @@ public R call(T t1) {
532532
* the Observables obtained from this transformation
533533
*/
534534
public static <T, R> Observable<R> mapMany(Observable<T> sequence, Func1<Observable<R>, T> func) {
535-
return wrap(OperationMap.mapMany(sequence, func));
535+
return OperationMap.mapMany(sequence, func);
536536
}
537537

538538
/**
@@ -598,7 +598,7 @@ public static <T> Observable<Notification<T>> materialize(final Observable<T> se
598598
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
599599
*/
600600
public static <T> Observable<T> merge(List<Observable<T>> source) {
601-
return wrap(OperationMerge.merge(source));
601+
return OperationMerge.merge(source);
602602
}
603603

604604
/**
@@ -616,7 +616,7 @@ public static <T> Observable<T> merge(List<Observable<T>> source) {
616616
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
617617
*/
618618
public static <T> Observable<T> merge(Observable<Observable<T>> source) {
619-
return wrap(OperationMerge.merge(source));
619+
return OperationMerge.merge(source);
620620
}
621621

622622
/**
@@ -634,7 +634,7 @@ public static <T> Observable<T> merge(Observable<Observable<T>> source) {
634634
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
635635
*/
636636
public static <T> Observable<T> merge(Observable<T>... source) {
637-
return wrap(OperationMerge.merge(source));
637+
return OperationMerge.merge(source);
638638
}
639639

640640
/**
@@ -654,7 +654,7 @@ public static <T> Observable<T> merge(Observable<T>... source) {
654654
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
655655
*/
656656
public static <T> Observable<T> mergeDelayError(List<Observable<T>> source) {
657-
return wrap(OperationMergeDelayError.mergeDelayError(source));
657+
return OperationMergeDelayError.mergeDelayError(source);
658658
}
659659

660660
/**
@@ -674,7 +674,7 @@ public static <T> Observable<T> mergeDelayError(List<Observable<T>> source) {
674674
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
675675
*/
676676
public static <T> Observable<T> mergeDelayError(Observable<Observable<T>> source) {
677-
return wrap(OperationMergeDelayError.mergeDelayError(source));
677+
return OperationMergeDelayError.mergeDelayError(source);
678678
}
679679

680680
/**
@@ -694,7 +694,7 @@ public static <T> Observable<T> mergeDelayError(Observable<Observable<T>> source
694694
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
695695
*/
696696
public static <T> Observable<T> mergeDelayError(Observable<T>... source) {
697-
return wrap(OperationMergeDelayError.mergeDelayError(source));
697+
return OperationMergeDelayError.mergeDelayError(source);
698698
}
699699

700700
/**
@@ -710,7 +710,7 @@ public static <T> Observable<T> mergeDelayError(Observable<T>... source) {
710710
* @return a Observable that never sends any information to a Observer
711711
*/
712712
public static <T> Observable<T> never() {
713-
return wrap(new NeverObservable<T>());
713+
return new NeverObservable<T>();
714714
}
715715

716716
/**
@@ -749,7 +749,7 @@ public static Subscription noOpSubscription() {
749749
* @return the source Observable, with its behavior modified as described
750750
*/
751751
public static <T> Observable<T> onErrorResumeNext(final Observable<T> that, final Func1<Observable<T>, Exception> resumeFunction) {
752-
return wrap(OperationOnErrorResumeNextViaFunction.onErrorResumeNextViaFunction(that, resumeFunction));
752+
return OperationOnErrorResumeNextViaFunction.onErrorResumeNextViaFunction(that, resumeFunction);
753753
}
754754

755755
/**
@@ -812,7 +812,7 @@ public Observable<T> call(Exception e) {
812812
* @return the source Observable, with its behavior modified as described
813813
*/
814814
public static <T> Observable<T> onErrorResumeNext(final Observable<T> that, final Observable<T> resumeSequence) {
815-
return wrap(OperationOnErrorResumeNextViaObservable.onErrorResumeNextViaObservable(that, resumeSequence));
815+
return OperationOnErrorResumeNextViaObservable.onErrorResumeNextViaObservable(that, resumeSequence);
816816
}
817817

818818
/**
@@ -839,7 +839,7 @@ public static <T> Observable<T> onErrorResumeNext(final Observable<T> that, fina
839839
* @return the source Observable, with its behavior modified as described
840840
*/
841841
public static <T> Observable<T> onErrorReturn(final Observable<T> that, Func1<T, Exception> resumeFunction) {
842-
return wrap(OperationOnErrorReturn.onErrorReturn(that, resumeFunction));
842+
return OperationOnErrorReturn.onErrorReturn(that, resumeFunction);
843843
}
844844

845845
/**
@@ -870,7 +870,7 @@ public static <T> Observable<T> onErrorReturn(final Observable<T> that, Func1<T,
870870
* @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
871871
*/
872872
public static <T> Observable<T> reduce(Observable<T> sequence, Func2<T, T, T> accumulator) {
873-
return wrap(OperationScan.scan(sequence, accumulator).last());
873+
return OperationScan.scan(sequence, accumulator).last();
874874
}
875875

876876
/**
@@ -941,7 +941,7 @@ public T call(T t1, T t2) {
941941
* @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
942942
*/
943943
public static <T> Observable<T> reduce(Observable<T> sequence, T initialValue, Func2<T, T, T> accumulator) {
944-
return wrap(OperationScan.scan(sequence, initialValue, accumulator).last());
944+
return OperationScan.scan(sequence, initialValue, accumulator).last();
945945
}
946946

947947
/**
@@ -1004,7 +1004,7 @@ public T call(T t1, T t2) {
10041004
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
10051005
*/
10061006
public static <T> Observable<T> scan(Observable<T> sequence, Func2<T, T, T> accumulator) {
1007-
return wrap(OperationScan.scan(sequence, accumulator));
1007+
return OperationScan.scan(sequence, accumulator);
10081008
}
10091009

10101010
/**
@@ -1061,7 +1061,7 @@ public T call(T t1, T t2) {
10611061
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
10621062
*/
10631063
public static <T> Observable<T> scan(Observable<T> sequence, T initialValue, Func2<T, T, T> accumulator) {
1064-
return wrap(OperationScan.scan(sequence, initialValue, accumulator));
1064+
return OperationScan.scan(sequence, initialValue, accumulator);
10651065
}
10661066

10671067
/**
@@ -1114,7 +1114,7 @@ public T call(T t1, T t2) {
11141114
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229847(v=vs.103).aspx">MSDN: Observable.Skip Method</a>
11151115
*/
11161116
public static <T> Observable<T> skip(final Observable<T> items, int num) {
1117-
return wrap(OperationSkip.skip(items, num));
1117+
return OperationSkip.skip(items, num);
11181118
}
11191119

11201120
/**
@@ -1132,7 +1132,7 @@ public static <T> Observable<T> skip(final Observable<T> items, int num) {
11321132
* @return a Observable that is a chronologically well-behaved version of the source Observable
11331133
*/
11341134
public static <T> Observable<T> synchronize(Observable<T> observable) {
1135-
return wrap(OperationSynchronize.synchronize(observable));
1135+
return OperationSynchronize.synchronize(observable);
11361136
}
11371137

11381138
/**
@@ -1155,7 +1155,7 @@ public static <T> Observable<T> synchronize(Observable<T> observable) {
11551155
* Observable
11561156
*/
11571157
public static <T> Observable<T> take(final Observable<T> items, final int num) {
1158-
return wrap(OperationTake.take(items, num));
1158+
return OperationTake.take(items, num);
11591159
}
11601160

11611161
/**
@@ -1178,7 +1178,7 @@ public static <T> Observable<T> take(final Observable<T> items, final int num) {
11781178
* items emitted by the source Observable
11791179
*/
11801180
public static <T> Observable<List<T>> toList(final Observable<T> that) {
1181-
return wrap(OperationToObservableList.toObservableList(that));
1181+
return OperationToObservableList.toObservableList(that);
11821182
}
11831183

11841184
/**
@@ -1198,7 +1198,7 @@ public static <T> Observable<List<T>> toList(final Observable<T> that) {
11981198
* @return a Observable that emits each item in the source Iterable sequence
11991199
*/
12001200
public static <T> Observable<T> toObservable(Iterable<T> iterable) {
1201-
return wrap(OperationToObservableIterable.toObservableIterable(iterable));
1201+
return OperationToObservableIterable.toObservableIterable(iterable);
12021202
}
12031203

12041204
/**
@@ -1233,7 +1233,7 @@ public static <T> Observable<T> toObservable(T... items) {
12331233
* @return
12341234
*/
12351235
public static <T> Observable<List<T>> toSortedList(Observable<T> sequence) {
1236-
return wrap(OperationToObservableSortedList.toSortedList(sequence));
1236+
return OperationToObservableSortedList.toSortedList(sequence);
12371237
}
12381238

12391239
/**
@@ -1247,7 +1247,7 @@ public static <T> Observable<List<T>> toSortedList(Observable<T> sequence) {
12471247
* @return
12481248
*/
12491249
public static <T> Observable<List<T>> toSortedList(Observable<T> sequence, Func2<Integer, T, T> sortFunction) {
1250-
return wrap(OperationToObservableSortedList.toSortedList(sequence, sortFunction));
1250+
return OperationToObservableSortedList.toSortedList(sequence, sortFunction);
12511251
}
12521252

12531253
/**
@@ -1261,40 +1261,14 @@ public static <T> Observable<List<T>> toSortedList(Observable<T> sequence, Func2
12611261
* @return
12621262
*/
12631263
public static <T> Observable<List<T>> toSortedList(Observable<T> sequence, final Object sortFunction) {
1264-
return wrap(OperationToObservableSortedList.toSortedList(sequence, new Func2<Integer, T, T>() {
1264+
return OperationToObservableSortedList.toSortedList(sequence, new Func2<Integer, T, T>() {
12651265

12661266
@Override
12671267
public Integer call(T t1, T t2) {
12681268
return Functions.execute(sortFunction, t1, t2);
12691269
}
12701270

1271-
}));
1272-
}
1273-
1274-
/**
1275-
* Allow wrapping responses with the <code>AbstractObservable</code> so that we have all of
1276-
* the utility methods available for subscribing.
1277-
* <p>
1278-
* This is not expected to benefit Java usage, but is intended for dynamic script which are a primary target of the Observable operations.
1279-
* <p>
1280-
* Since they are dynamic they can execute the "hidden" methods on <code>AbstractObservable</code> while appearing to only receive an <code>Observable</code> without first casting.
1281-
*
1282-
* @param o
1283-
* @return
1284-
*/
1285-
private static <T> Observable<T> wrap(final Observable<T> o) {
1286-
if (o instanceof Observable) {
1287-
// if the Observable is already an AbstractObservable, don't wrap it again.
1288-
return (Observable<T>) o;
1289-
}
1290-
return new Observable<T>() {
1291-
1292-
@Override
1293-
public Subscription subscribe(Observer<T> observer) {
1294-
return o.subscribe(observer);
1295-
}
1296-
1297-
};
1271+
});
12981272
}
12991273

13001274
/**
@@ -1322,7 +1296,7 @@ public Subscription subscribe(Observer<T> observer) {
13221296
* @return a Observable that emits the zipped results
13231297
*/
13241298
public static <R, T0, T1> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Func2<R, T0, T1> reduceFunction) {
1325-
return wrap(OperationZip.zip(w0, w1, reduceFunction));
1299+
return OperationZip.zip(w0, w1, reduceFunction);
13261300
}
13271301

13281302
/**
@@ -1389,7 +1363,7 @@ public R call(T0 t0, T1 t1) {
13891363
* @return a Observable that emits the zipped results
13901364
*/
13911365
public static <R, T0, T1, T2> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<R, T0, T1, T2> function) {
1392-
return wrap(OperationZip.zip(w0, w1, w2, function));
1366+
return OperationZip.zip(w0, w1, w2, function);
13931367
}
13941368

13951369
/**
@@ -1461,7 +1435,7 @@ public R call(T0 t0, T1 t1, T2 t2) {
14611435
* @return a Observable that emits the zipped results
14621436
*/
14631437
public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<R, T0, T1, T2, T3> reduceFunction) {
1464-
return wrap(OperationZip.zip(w0, w1, w2, w3, reduceFunction));
1438+
return OperationZip.zip(w0, w1, w2, w3, reduceFunction);
14651439
}
14661440

14671441
/**

0 commit comments

Comments
 (0)