|
36 | 36 | import org.mockito.MockitoAnnotations;
|
37 | 37 |
|
38 | 38 | import rx.observables.GroupedObservable;
|
| 39 | +import rx.operators.OperationAll; |
39 | 40 | import rx.operators.OperationConcat;
|
40 | 41 | import rx.operators.OperationDefer;
|
41 | 42 | import rx.operators.OperationDematerialize;
|
@@ -1665,6 +1666,35 @@ public T call(T t1, T t2) {
|
1665 | 1666 | });
|
1666 | 1667 | }
|
1667 | 1668 |
|
| 1669 | + /** |
| 1670 | + * Determines whether all elements of an observable sequence satisfies a condition. |
| 1671 | + * @param sequence an observable sequence whose elements to apply the predicate to. |
| 1672 | + * @param predicate a function to test each element for a condition. |
| 1673 | + * @param <T> the type of observable. |
| 1674 | + * @return true if all elements of an observable sequence satisfies a condition; otherwise, false. |
| 1675 | + */ |
| 1676 | + public static <T> Observable<Boolean> all(final Observable<T> sequence, final Func1<T, Boolean> predicate) { |
| 1677 | + return _create(OperationAll.all(sequence, predicate)); |
| 1678 | + } |
| 1679 | + |
| 1680 | + /** |
| 1681 | + * Determines whether all elements of an observable sequence satisfies a condition. |
| 1682 | + * @param sequence an observable sequence whose elements to apply the predicate to. |
| 1683 | + * @param predicate a function to test each element for a condition. |
| 1684 | + * @param <T> the type of observable. |
| 1685 | + * @return true if all elements of an observable sequence satisfies a condition; otherwise, false. |
| 1686 | + */ |
| 1687 | + public static <T> Observable<Boolean> all(final Observable<T> sequence, Object predicate) { |
| 1688 | + final FuncN _f = Functions.from(predicate); |
| 1689 | + |
| 1690 | + return all(sequence, new Func1<T, Boolean>() { |
| 1691 | + @Override |
| 1692 | + public Boolean call(T t) { |
| 1693 | + return (Boolean) _f.call(t); |
| 1694 | + } |
| 1695 | + }); |
| 1696 | + } |
| 1697 | + |
1668 | 1698 | /**
|
1669 | 1699 | * Returns an Observable that skips the first <code>num</code> items emitted by the source
|
1670 | 1700 | * Observable. You can ignore the first <code>num</code> items emitted by an Observable and attend
|
@@ -2973,6 +3003,24 @@ public Observable<T> scan(final T initialValue, final Object accumulator) {
|
2973 | 3003 | return scan(this, initialValue, accumulator);
|
2974 | 3004 | }
|
2975 | 3005 |
|
| 3006 | + /** |
| 3007 | + * Determines whether all elements of an observable sequence satisfies a condition. |
| 3008 | + * @param predicate a function to test each element for a condition. |
| 3009 | + * @return true if all elements of an observable sequence satisfies a condition; otherwise, false. |
| 3010 | + */ |
| 3011 | + public Observable<Boolean> all(Func1<T, Boolean> predicate) { |
| 3012 | + return all(this, predicate); |
| 3013 | + } |
| 3014 | + |
| 3015 | + /** |
| 3016 | + * Determines whether all elements of an observable sequence satisfies a condition. |
| 3017 | + * @param predicate a function to test each element for a condition. |
| 3018 | + * @return true if all elements of an observable sequence satisfies a condition; otherwise, false. |
| 3019 | + */ |
| 3020 | + public Observable<Boolean> all(Object predicate) { |
| 3021 | + return all(this, predicate); |
| 3022 | + } |
| 3023 | + |
2976 | 3024 | /**
|
2977 | 3025 | * Returns an Observable that skips the first <code>num</code> items emitted by the source
|
2978 | 3026 | * Observable.
|
|
0 commit comments