Skip to content

Commit

Permalink
2.x: small note on Maybe.defaultIfEmpty regarding toSingle (ReactiveX…
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd authored Jul 15, 2017
1 parent 46ec6a6 commit 22f31f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/io/reactivex/Maybe.java
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,10 @@ public final Single<Long> count() {
* Returns a Maybe that emits the item emitted by the source Maybe or a specified default item
* if the source Maybe is empty.
* <p>
* Note that the result Maybe is semantically equivalent to a {@code Single}, since it's guaranteed
* to emit exactly one item or an error. See {@link #toSingle(Object)} for a method with equivalent
* behavior which returns a {@code Single}.
* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/defaultIfEmpty.png" alt="">
* <dl>
* <dt><b>Scheduler:</b></dt>
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/io/reactivex/JavadocWording.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ public void maybeDocRefersToMaybeTypes() throws Exception {
for (;;) {
int idx = m.javadoc.indexOf("Single", jdx);
if (idx >= 0) {
if (!m.signature.contains("Single")) {
int j = m.javadoc.indexOf("#toSingle", jdx);
int k = m.javadoc.indexOf("{@code Single", jdx);
if (!m.signature.contains("Single") && (j + 3 != idx && k + 7 != idx)) {
e.append("java.lang.RuntimeException: Maybe doc mentions Single but not in the signature\r\n at io.reactivex.")
.append("Maybe (Maybe.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
.append("Maybe(Maybe.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
Expand Down

0 comments on commit 22f31f5

Please sign in to comment.