You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rxjava-core/src/main/java/rx/Observable.java
+251Lines changed: 251 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -408,6 +408,66 @@ public void call(Object args) {
408
408
});
409
409
}
410
410
411
+
/**
412
+
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
413
+
*
414
+
* @return The single element in the observable sequence.
415
+
*/
416
+
publicTsingle() {
417
+
returnsingle(this);
418
+
}
419
+
420
+
/**
421
+
* Returns the only element of an observable sequence that matches the predicate and throws an exception if there is not exactly one element in the observable sequence.
422
+
*
423
+
* @param predicate A predicate function to evaluate for elements in the sequence.
424
+
* @return The single element in the observable sequence.
425
+
*/
426
+
publicTsingle(Func1<T, Boolean> predicate) {
427
+
returnsingle(this, predicate);
428
+
}
429
+
430
+
/**
431
+
* Returns the only element of an observable sequence that matches the predicate and throws an exception if there is not exactly one element in the observable sequence.
432
+
*
433
+
* @param predicate A predicate function to evaluate for elements in the sequence.
434
+
* @return The single element in the observable sequence.
435
+
*/
436
+
publicTsingle(Objectpredicate) {
437
+
returnsingle(this, predicate);
438
+
}
439
+
440
+
/**
441
+
* Returns the only element of an observable sequence, or a default value if the observable sequence is empty.
442
+
*
443
+
* @param defaultValue default value for a sequence.
444
+
* @return The single element in the observable sequence, or a default value if no value is found.
445
+
*/
446
+
publicTsingleOrDefault(TdefaultValue) {
447
+
returnsingleOrDefault(this, defaultValue);
448
+
}
449
+
450
+
/**
451
+
* Returns the only element of an observable sequence that matches the predicate, or a default value if no value is found.
452
+
* @param defaultValue default value for a sequence.
453
+
* @param predicate A predicate function to evaluate for elements in the sequence.
454
+
* @return The single element in the observable sequence, or a default value if no value is found.
@@ -1648,6 +1710,127 @@ public Iterator<T> iterator() {
1648
1710
};
1649
1711
}
1650
1712
1713
+
/**
1714
+
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
1715
+
*
1716
+
* @param that
1717
+
* the source Observable
1718
+
* @return The single element in the observable sequence.
1719
+
* @throws IllegalStateException
1720
+
* if there is not exactly one element in the observable sequence
1721
+
*/
1722
+
publicstatic <T> Tsingle(Observable<T> that) {
1723
+
returnsingleOrDefault(that, false, null);
1724
+
}
1725
+
1726
+
/**
1727
+
* Returns the only element of an observable sequence that matches the predicate and throws an exception if there is not exactly one element in the observable sequence.
1728
+
*
1729
+
* @param that
1730
+
* the source Observable
1731
+
* @param predicate
1732
+
* A predicate function to evaluate for elements in the sequence.
1733
+
* @return The single element in the observable sequence.
1734
+
* @throws IllegalStateException
1735
+
* if there is not exactly one element in the observable sequence that matches the predicate
* Returns the only element of an observable sequence that matches the predicate and throws an exception if there is not exactly one element in the observable sequence.
1743
+
*
1744
+
* @param that
1745
+
* the source Observable
1746
+
* @param predicate
1747
+
* A predicate function to evaluate for elements in the sequence.
1748
+
* @return The single element in the observable sequence.
1749
+
* @throws IllegalStateException
1750
+
* if there is not exactly one element in the observable sequence that matches the predicate
0 commit comments