public static <X> CompletionStage<X> toFuture(Publisher<X> publisher) {
    Objects.requireNonNull(publisher, "publisher");
    return Flowable.fromPublisher(publisher).singleOrError().to(singleToFuture());
  }
Converts a publisher (with a single result) to {@link CompletionStage}.
criteria/common/src/org/immutables/criteria/repository/Publishers.java