@Override public <T> F.Promise<T> execute(final ClientRequest<T> clientRequest) { return F.Promise.<T>wrap(scalaClient.execute(clientRequest)); }
@Override public <T> F.Promise<T> execute(final ClientRequest<T> clientRequest) { return F.Promise.<T>wrap(scalaClient.execute(clientRequest)); }
default F.Promise<Result> wrapAndReturn(Future<play.api.mvc.Result> result) { JFunction1<play.api.mvc.Result, Result> resultConverter = scalaResult -> (Result) () -> scalaResult; ExecutionContext ec = play.api.libs.concurrent.Execution.defaultContext(); return F.Promise.wrap(result.map(resultConverter, ec)); }
/** * Completes this promise with the specified Promise, once that Promise is completed. * * @param other The value to complete with * @param ec An execution context * @return A promise giving the result of attempting to complete this promise with the other * promise. If the completion was successful then the result will be true, if the * completion couldn't occur then the result will be false. */ public Promise<Boolean> tryCompleteWith(Promise other, ExecutionContext ec) { Promise<Boolean> r = Promise.wrap(FPromiseHelper.tryCompleteWith(this.promise, other.future, ec)); return r; } }
/** * Completes this promise with the specified Promise, once that Promise is completed. * * @param other The value to complete with * @param ec An execution context * @return A promise giving the result of attempting to complete this promise with the other * promise. If the completion was successful then the result will be a null value, * if the completion failed then the result will be an IllegalStateException. */ public Promise<Void> completeWith(Promise other, ExecutionContext ec) { Promise<Void> r = Promise.wrap(FPromiseHelper.completeWith(this.promise, other.future, ec)); return r; }
/** * Zips the values of this promise with <code>another</code>, and creates a new promise holding the tuple of their results * @param another */ public <B> Promise<Tuple<A, B>> zip(Promise<B> another) { return wrap(wrapped().zip(another.wrapped())).map( new Function<scala.Tuple2<A, B>, Tuple<A, B>>() { public Tuple<A, B> apply(scala.Tuple2<A, B> scalaTuple) { return new Tuple(scalaTuple._1, scalaTuple._2); } } ); }
private static Result wrapScalaResult(scala.concurrent.Future<play.api.mvc.Result> result, long timeout) { if (result == null) { return null; } else { final play.api.mvc.Result scalaResult = Promise.wrap(result).get(timeout); return () -> scalaResult; } }