sqlbrite/src/main/java/com/squareup/sqlbrite3/QueryObservable.java
@RequiresApi(Build.VERSION_CODES.N)
  @CheckResult @NonNull
  public final <T> Observable<Optional<T>> mapToOptional(@NonNull Function<Cursor, T> mapper) {
    return lift(Query.mapToOptional(mapper));
  }
@RequiresApi(Build.VERSION_CODES.N)
  @CheckResult @NonNull
  public final <T> Observable<Optional<T>> mapToOptional(@NonNull Function<Cursor, T> mapper) {
    return lift(Query.mapToOptional(mapper));
  }
@ RequiresApi ( Build . VERSION_CODES . N ) @ CheckResult @ NonNull public final < T > Observable < Optional < T > > mapToOptional ( @ NonNull Function < Cursor , T > mapper ) { return lift ( Query . mapToOptional ( mapper ) ) ; }
Given a function mapping the current row of a {@link Cursor} to {@code T}, transform each
emitted {@link Query} which returns a single row to {@code Optional<T>}.
<p>
It is an error for a query to pass through this operator with more than 1 row in its result
set. Use {@code LIMIT 1} on the underlying SQL query to prevent this. Result sets with 0 rows
emit {@link Optional#empty() Optional.empty()}
<p>
This method is equivalent to:
<pre>{@code
flatMap(q -> q.asRows(mapper).take(1).map(Optional::of).defaultIfEmpty(Optional.empty())
}</pre>
and a convenience operator for:
<pre>{@code
lift(Query.mapToOptional(mapper))
}</pre>

@param mapper Maps the current {@link Cursor} row to {@code T}. May not return null.
Given a function mapping the current row of a { @link Cursor } to { @code T } transform each emitted { @link Query } which returns a single row to { @code Optional<T > } . <p > It is an error for a query to pass through this operator with more than 1 row in its result set . Use { @code LIMIT 1 } on the underlying SQL query to prevent this . Result sets with 0 rows emit { @link Optional#empty () Optional . empty () } <p > This method is equivalent to : <pre > { @code flatMap ( q - > q . asRows ( mapper ) . take ( 1 ) . map ( Optional :: of ) . defaultIfEmpty ( Optional . empty () ) } < / pre > and a convenience operator for : <pre > { @code lift ( Query . mapToOptional ( mapper )) } < / pre >