src/main/java/io/reactivex/internal/operators/mixed/ScalarXMapZHelper.java
static <T> boolean tryAsCompletable(Object source,
            Function<? super T, ? extends CompletableSource> mapper,
            CompletableObserver observer) {
        if (source instanceof Callable) {
            @SuppressWarnings("unchecked")
            Callable<T> call = (Callable<T>) source;
            CompletableSource cs = null;
            try {
                T item = call.call();
                if (item != null) {
                    cs = ObjectHelper.requireNonNull(mapper.apply(item), "The mapper returned a null CompletableSource");
                }
            } catch (Throwable ex) {
                Exceptions.throwIfFatal(ex);
                EmptyDisposable.error(ex, observer);
                return true;
            }

            if (cs == null) {
                EmptyDisposable.complete(observer);
            } else {
                cs.subscribe(observer);
            }
            return true;
        }
        return false;
    }
static <T> boolean tryAsCompletable(Object source,
            Function<? super T, ? extends CompletableSource> mapper,
            CompletableObserver observer) {
        if (source instanceof Callable) {
            @SuppressWarnings("unchecked")
            Callable<T> call = (Callable<T>) source;
            CompletableSource cs = null;
            try {
                T item = call.call();
                if (item != null) {
                    cs = ObjectHelper.requireNonNull(mapper.apply(item), "The mapper returned a null CompletableSource");
                }
            } catch (Throwable ex) {
                Exceptions.throwIfFatal(ex);
                EmptyDisposable.error(ex, observer);
                return true;
            }

            if (cs == null) {
                EmptyDisposable.complete(observer);
            } else {
                cs.subscribe(observer);
            }
            return true;
        }
        return false;
    }
static < T > boolean tryAsCompletable ( Object source , Function < ? super T , ? extends CompletableSource > mapper , CompletableObserver observer ) { if ( source instanceof Callable ) { @ SuppressWarnings ( "unchecked" ) Callable < T > call = ( Callable < T > ) source ; CompletableSource cs = null ; try { T item = call . call ( ) ; if ( item != null ) { cs = ObjectHelper . requireNonNull ( mapper . apply ( item ) , "The mapper returned a null CompletableSource" ) ; } } catch ( Throwable ex ) { Exceptions . throwIfFatal ( ex ) ; EmptyDisposable . error ( ex , observer ) ; return true ; } if ( cs == null ) { EmptyDisposable . complete ( observer ) ; } else { cs . subscribe ( observer ) ; } return true ; } return false ; }
Try subscribing to a {@link CompletableSource} mapped from
a scalar source (which implements {@link Callable}).
@param <T> the upstream value type
@param source the source reactive type ({@code Flowable} or {@code Observable})
possibly implementing {@link Callable}.
@param mapper the function that turns the scalar upstream value into a
{@link CompletableSource}
@param observer the consumer to subscribe to the mapped {@link CompletableSource}
@return true if a subscription did happen and the regular path should be skipped
Try subscribing to a {