52
52
import rx .util .Func2 ;
53
53
import rx .util .Func3 ;
54
54
import rx .util .Func4 ;
55
+ import rx .util .FuncN ;
55
56
import rx .util .Functions ;
56
57
57
58
/**
@@ -301,7 +302,7 @@ private static void handleError(Exception e) {
301
302
* @param args
302
303
*/
303
304
private void executeCallback (final Object callback , Object ... args ) {
304
- Functions .execute (callback , args );
305
+ Functions .from (callback ). call ( args );
305
306
}
306
307
307
308
/**
@@ -395,11 +396,13 @@ public static <T> Observable<T> create(Func1<Observer<T>, Subscription> func) {
395
396
* @return a Observable that, when a Observer subscribes to it, will execute the given function
396
397
*/
397
398
public static <T > Observable <T > create (final Object callback ) {
399
+ @ SuppressWarnings ("rawtypes" )
400
+ final FuncN _f = Functions .from (callback );
398
401
return create (new Func1 <Observer <T >, Subscription >() {
399
402
400
403
@ Override
401
404
public Subscription call (Observer <T > t1 ) {
402
- return Functions . execute ( callback , t1 );
405
+ return ( Subscription ) _f . call ( t1 );
403
406
}
404
407
405
408
});
@@ -469,11 +472,13 @@ public static <T> Observable<T> filter(Observable<T> that, Func1<T, Boolean> pre
469
472
* evaluates as true
470
473
*/
471
474
public static <T > Observable <T > filter (Observable <T > that , final Object function ) {
475
+ @ SuppressWarnings ("rawtypes" )
476
+ final FuncN _f = Functions .from (function );
472
477
return filter (that , new Func1 <T , Boolean >() {
473
478
474
479
@ Override
475
480
public Boolean call (T t1 ) {
476
- return Functions . execute ( function , t1 );
481
+ return ( Boolean ) _f . call ( t1 );
477
482
478
483
}
479
484
@@ -597,11 +602,14 @@ public static <T, R> Observable<R> map(Observable<T> sequence, Func1<T, R> func)
597
602
* in the sequence emitted by the source Observable
598
603
*/
599
604
public static <T , R > Observable <R > map (Observable <T > sequence , final Object function ) {
605
+ @ SuppressWarnings ("rawtypes" )
606
+ final FuncN _f = Functions .from (function );
600
607
return map (sequence , new Func1 <T , R >() {
601
608
609
+ @ SuppressWarnings ("unchecked" )
602
610
@ Override
603
611
public R call (T t1 ) {
604
- return Functions . execute ( function , t1 );
612
+ return ( R ) _f . call ( t1 );
605
613
}
606
614
607
615
});
@@ -656,11 +664,14 @@ public static <T, R> Observable<R> mapMany(Observable<T> sequence, Func1<T, Obse
656
664
* Observables obtained from this transformation
657
665
*/
658
666
public static <T , R > Observable <R > mapMany (Observable <T > sequence , final Object function ) {
667
+ @ SuppressWarnings ("rawtypes" )
668
+ final FuncN _f = Functions .from (function );
659
669
return mapMany (sequence , new Func1 <T , R >() {
660
670
671
+ @ SuppressWarnings ("unchecked" )
661
672
@ Override
662
673
public R call (T t1 ) {
663
- return Functions . execute ( function , t1 );
674
+ return ( R ) _f . call ( t1 );
664
675
}
665
676
666
677
});
@@ -876,11 +887,14 @@ public static <T> Observable<T> onErrorResumeNext(final Observable<T> that, fina
876
887
* @return the source Observable, with its behavior modified as described
877
888
*/
878
889
public static <T > Observable <T > onErrorResumeNext (final Observable <T > that , final Object resumeFunction ) {
890
+ @ SuppressWarnings ("rawtypes" )
891
+ final FuncN _f = Functions .from (resumeFunction );
879
892
return onErrorResumeNext (that , new Func1 <Exception , Observable <T >>() {
880
893
894
+ @ SuppressWarnings ("unchecked" )
881
895
@ Override
882
896
public Observable <T > call (Exception e ) {
883
- return Functions . execute ( resumeFunction , e );
897
+ return ( Observable < T >) _f . call ( e );
884
898
}
885
899
});
886
900
}
@@ -999,11 +1013,14 @@ public static <T> Observable<T> reduce(Observable<T> sequence, Func2<T, T, T> ac
999
1013
* @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
1000
1014
*/
1001
1015
public static <T > Observable <T > reduce (final Observable <T > sequence , final Object accumulator ) {
1016
+ @ SuppressWarnings ("rawtypes" )
1017
+ final FuncN _f = Functions .from (accumulator );
1002
1018
return reduce (sequence , new Func2 <T , T , T >() {
1003
1019
1020
+ @ SuppressWarnings ("unchecked" )
1004
1021
@ Override
1005
1022
public T call (T t1 , T t2 ) {
1006
- return Functions . execute ( accumulator , t1 , t2 );
1023
+ return ( T ) _f . call ( t1 , t2 );
1007
1024
}
1008
1025
1009
1026
});
@@ -1071,11 +1088,14 @@ public static <T> Observable<T> reduce(Observable<T> sequence, T initialValue, F
1071
1088
* @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
1072
1089
*/
1073
1090
public static <T > Observable <T > reduce (final Observable <T > sequence , final T initialValue , final Object accumulator ) {
1091
+ @ SuppressWarnings ("rawtypes" )
1092
+ final FuncN _f = Functions .from (accumulator );
1074
1093
return reduce (sequence , initialValue , new Func2 <T , T , T >() {
1075
1094
1095
+ @ SuppressWarnings ("unchecked" )
1076
1096
@ Override
1077
1097
public T call (T t1 , T t2 ) {
1078
- return Functions . execute ( accumulator , t1 , t2 );
1098
+ return ( T ) _f . call ( t1 , t2 );
1079
1099
}
1080
1100
1081
1101
});
@@ -1126,11 +1146,14 @@ public static <T> Observable<T> scan(Observable<T> sequence, Func2<T, T, T> accu
1126
1146
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
1127
1147
*/
1128
1148
public static <T > Observable <T > scan (final Observable <T > sequence , final Object accumulator ) {
1149
+ @ SuppressWarnings ("rawtypes" )
1150
+ final FuncN _f = Functions .from (accumulator );
1129
1151
return scan (sequence , new Func2 <T , T , T >() {
1130
1152
1153
+ @ SuppressWarnings ("unchecked" )
1131
1154
@ Override
1132
1155
public T call (T t1 , T t2 ) {
1133
- return Functions . execute ( accumulator , t1 , t2 );
1156
+ return ( T ) _f . call ( t1 , t2 );
1134
1157
}
1135
1158
1136
1159
});
@@ -1185,11 +1208,14 @@ public static <T> Observable<T> scan(Observable<T> sequence, T initialValue, Fun
1185
1208
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
1186
1209
*/
1187
1210
public static <T > Observable <T > scan (final Observable <T > sequence , final T initialValue , final Object accumulator ) {
1211
+ @ SuppressWarnings ("rawtypes" )
1212
+ final FuncN _f = Functions .from (accumulator );
1188
1213
return scan (sequence , initialValue , new Func2 <T , T , T >() {
1189
1214
1215
+ @ SuppressWarnings ("unchecked" )
1190
1216
@ Override
1191
1217
public T call (T t1 , T t2 ) {
1192
- return Functions . execute ( accumulator , t1 , t2 );
1218
+ return ( T ) _f . call ( t1 , t2 );
1193
1219
}
1194
1220
1195
1221
});
@@ -1359,11 +1385,13 @@ public static <T> Observable<List<T>> toSortedList(Observable<T> sequence, Func2
1359
1385
* @return
1360
1386
*/
1361
1387
public static <T > Observable <List <T >> toSortedList (Observable <T > sequence , final Object sortFunction ) {
1388
+ @ SuppressWarnings ("rawtypes" )
1389
+ final FuncN _f = Functions .from (sortFunction );
1362
1390
return OperationToObservableSortedList .toSortedList (sequence , new Func2 <T , T , Integer >() {
1363
1391
1364
1392
@ Override
1365
1393
public Integer call (T t1 , T t2 ) {
1366
- return Functions . execute ( sortFunction , t1 , t2 );
1394
+ return ( Integer ) _f . call ( t1 , t2 );
1367
1395
}
1368
1396
1369
1397
});
@@ -1422,11 +1450,14 @@ public static <R, T0, T1> Observable<R> zip(Observable<T0> w0, Observable<T1> w1
1422
1450
* @return a Observable that emits the zipped results
1423
1451
*/
1424
1452
public static <R , T0 , T1 > Observable <R > zip (Observable <T0 > w0 , Observable <T1 > w1 , final Object function ) {
1453
+ @ SuppressWarnings ("rawtypes" )
1454
+ final FuncN _f = Functions .from (function );
1425
1455
return zip (w0 , w1 , new Func2 <T0 , T1 , R >() {
1426
1456
1457
+ @ SuppressWarnings ("unchecked" )
1427
1458
@ Override
1428
1459
public R call (T0 t0 , T1 t1 ) {
1429
- return Functions . execute ( function , t0 , t1 );
1460
+ return ( R ) _f . call ( t0 , t1 );
1430
1461
}
1431
1462
1432
1463
});
@@ -1493,11 +1524,14 @@ public static <R, T0, T1, T2> Observable<R> zip(Observable<T0> w0, Observable<T1
1493
1524
* @return a Observable that emits the zipped results
1494
1525
*/
1495
1526
public static <R , T0 , T1 , T2 > Observable <R > zip (Observable <T0 > w0 , Observable <T1 > w1 , Observable <T2 > w2 , final Object function ) {
1527
+ @ SuppressWarnings ("rawtypes" )
1528
+ final FuncN _f = Functions .from (function );
1496
1529
return zip (w0 , w1 , w2 , new Func3 <T0 , T1 , T2 , R >() {
1497
1530
1531
+ @ SuppressWarnings ("unchecked" )
1498
1532
@ Override
1499
1533
public R call (T0 t0 , T1 t1 , T2 t2 ) {
1500
- return Functions . execute ( function , t0 , t1 , t2 );
1534
+ return ( R ) _f . call ( t0 , t1 , t2 );
1501
1535
}
1502
1536
1503
1537
});
@@ -1566,11 +1600,14 @@ public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<T0> w0, Observabl
1566
1600
* @return a Observable that emits the zipped results
1567
1601
*/
1568
1602
public static <R , T0 , T1 , T2 , T3 > Observable <R > zip (Observable <T0 > w0 , Observable <T1 > w1 , Observable <T2 > w2 , Observable <T3 > w3 , final Object function ) {
1603
+ @ SuppressWarnings ("rawtypes" )
1604
+ final FuncN _f = Functions .from (function );
1569
1605
return zip (w0 , w1 , w2 , w3 , new Func4 <T0 , T1 , T2 , T3 , R >() {
1570
1606
1607
+ @ SuppressWarnings ("unchecked" )
1571
1608
@ Override
1572
1609
public R call (T0 t0 , T1 t1 , T2 t2 , T3 t3 ) {
1573
- return Functions . execute ( function , t0 , t1 , t2 , t3 );
1610
+ return ( R ) _f . call ( t0 , t1 , t2 , t3 );
1574
1611
}
1575
1612
1576
1613
});
@@ -1588,7 +1625,7 @@ public R call(T0 t0, T1 t1, T2 t2, T3 t3) {
1588
1625
* @return a Observable that emits only those items in the original Observable that the filter
1589
1626
* evaluates as <code>true</code>
1590
1627
*/
1591
- public Observable <T > filter (Func1 <Boolean , T > predicate ) {
1628
+ public Observable <T > filter (Func1 <T , Boolean > predicate ) {
1592
1629
return filter (this , predicate );
1593
1630
}
1594
1631
@@ -1605,10 +1642,12 @@ public Observable<T> filter(Func1<Boolean, T> predicate) {
1605
1642
* evaluates as "true"
1606
1643
*/
1607
1644
public Observable <T > filter (final Object callback ) {
1645
+ @ SuppressWarnings ("rawtypes" )
1646
+ final FuncN _f = Functions .from (callback );
1608
1647
return filter (this , new Func1 <T , Boolean >() {
1609
1648
1610
1649
public Boolean call (T t1 ) {
1611
- return Functions . execute ( callback , t1 );
1650
+ return ( Boolean ) _f . call ( t1 );
1612
1651
}
1613
1652
});
1614
1653
}
@@ -1638,7 +1677,7 @@ public Observable<T> last() {
1638
1677
* @return a Observable that emits a sequence that is the result of applying the transformation
1639
1678
* closure to each item in the sequence emitted by the input Observable.
1640
1679
*/
1641
- public <R > Observable <R > map (Func1 <R , T > func ) {
1680
+ public <R > Observable <R > map (Func1 <T , R > func ) {
1642
1681
return map (this , func );
1643
1682
}
1644
1683
@@ -1655,10 +1694,13 @@ public <R> Observable<R> map(Func1<R, T> func) {
1655
1694
* closure to each item in the sequence emitted by the input Observable.
1656
1695
*/
1657
1696
public <R > Observable <R > map (final Object callback ) {
1697
+ @ SuppressWarnings ("rawtypes" )
1698
+ final FuncN _f = Functions .from (callback );
1658
1699
return map (this , new Func1 <T , R >() {
1659
1700
1701
+ @ SuppressWarnings ("unchecked" )
1660
1702
public R call (T t1 ) {
1661
- return Functions . execute ( callback , t1 );
1703
+ return ( R ) _f . call ( t1 );
1662
1704
}
1663
1705
});
1664
1706
}
@@ -1698,10 +1740,13 @@ public <R> Observable<R> mapMany(Func1<T, Observable<R>> func) {
1698
1740
* Observables obtained from this transformation.
1699
1741
*/
1700
1742
public <R > Observable <R > mapMany (final Object callback ) {
1743
+ @ SuppressWarnings ("rawtypes" )
1744
+ final FuncN _f = Functions .from (callback );
1701
1745
return mapMany (this , new Func1 <T , Observable <R >>() {
1702
1746
1747
+ @ SuppressWarnings ("unchecked" )
1703
1748
public Observable <R > call (T t1 ) {
1704
- return Functions . execute ( callback , t1 );
1749
+ return ( Observable < R >) _f . call ( t1 );
1705
1750
}
1706
1751
});
1707
1752
}
@@ -1771,10 +1816,13 @@ public Observable<T> onErrorResumeNext(final Func1<Exception, Observable<T>> res
1771
1816
* @return the original Observable with appropriately modified behavior
1772
1817
*/
1773
1818
public Observable <T > onErrorResumeNext (final Object resumeFunction ) {
1819
+ @ SuppressWarnings ("rawtypes" )
1820
+ final FuncN _f = Functions .from (resumeFunction );
1774
1821
return onErrorResumeNext (this , new Func1 <Exception , Observable <T >>() {
1775
1822
1823
+ @ SuppressWarnings ("unchecked" )
1776
1824
public Observable <T > call (Exception e ) {
1777
- return Functions . execute ( resumeFunction , e );
1825
+ return ( Observable < T >) _f . call ( e );
1778
1826
}
1779
1827
});
1780
1828
}
@@ -1857,10 +1905,13 @@ public Observable<T> onErrorReturn(Func1<Exception, T> resumeFunction) {
1857
1905
* @return the original Observable with appropriately modified behavior
1858
1906
*/
1859
1907
public Observable <T > onErrorReturn (final Object resumeFunction ) {
1908
+ @ SuppressWarnings ("rawtypes" )
1909
+ final FuncN _f = Functions .from (resumeFunction );
1860
1910
return onErrorReturn (this , new Func1 <Exception , T >() {
1861
1911
1912
+ @ SuppressWarnings ("unchecked" )
1862
1913
public T call (Exception e ) {
1863
- return Functions . execute ( resumeFunction , e );
1914
+ return ( T ) _f . call ( e );
1864
1915
}
1865
1916
});
1866
1917
}
0 commit comments