private static Result wrapScalaResult(scala.concurrent.Future<play.api.mvc.Result> result, long timeout) { if (result == null) { return null; } else { try { final play.api.mvc.Result scalaResult = FutureConverters.toJava(result).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS); return scalaResult.asJava(); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw new RuntimeException(e.getCause()); } } catch (InterruptedException | TimeoutException e) { throw new RuntimeException(e); } } }
/** * @deprecated use {@link Result#status()} instead. */ @Deprecated public static int status(Result result) { return result.toScala().header().status(); }
/** * Change the Content-Type header for this result. */ public Status as(String contentType) { wrappedResult = wrappedResult.as(contentType); return this; }
/** * Sets a new flash for this result, discarding the existing flash. * * @param flash the flash to set with this result * @return the new result */ public Result withFlash(Flash flash) { play.api.mvc.Result.warnFlashingIfNotRedirect(flash.asScala(), header.asScala()); return new Result(header, body, session, flash, cookies); }
/** * Convert this result to a Scala result. * * @return the Scala result. */ public play.api.mvc.Result asScala() { return new play.api.mvc.Result( header.asScala(), body.asScala(), session == null ? Scala.None() : Scala.Option(play.api.mvc.Session.fromJavaSession(session)), flash == null ? Scala.None() : Scala.Option(play.api.mvc.Flash.fromJavaFlash(flash)), JavaHelpers$.MODULE$.cookiesToScalaCookies(cookies) ); } }
public String toString() { return wrappedResult.toString(); }
/** * Sets a new flash for this result, discarding the existing flash. * * @param flash the flash to set with this result * @return the new result */ public Result withFlash(Flash flash) { play.api.mvc.Result.warnFlashingIfNotRedirect(flash.asScala(), header.asScala()); return new Result(header, body, session, flash, cookies); }
/** * Convert this result to a Scala result. * * @return the Scala result. */ public play.api.mvc.Result asScala() { return new play.api.mvc.Result( header.asScala(), body.asScala(), session == null ? Scala.None() : Scala.Option(play.api.mvc.Session.fromJavaSession(session)), flash == null ? Scala.None() : Scala.Option(play.api.mvc.Flash.fromJavaFlash(flash)), JavaHelpers$.MODULE$.cookiesToScalaCookies(cookies) ); } }
private static Result wrapScalaResult(scala.concurrent.Future<play.api.mvc.Result> result, long timeout) { if (result == null) { return null; } else { try { final play.api.mvc.Result scalaResult = FutureConverters.toJava(result).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS); return scalaResult.asJava(); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw new RuntimeException(e.getCause()); } } catch (InterruptedException | TimeoutException e) { throw new RuntimeException(e); } } }
/** * Sets a new flash for this result, discarding the existing flash. * * @param flash the flash to set with this result * @return the new result */ public Result withFlash(Flash flash) { play.api.mvc.Result.warnFlashingIfNotRedirect(flash.asScala(), header.asScala()); return new Result(header, body, session, flash, cookies); }
/** * Convert this result to a Scala result. * * @return the Scala result. */ public play.api.mvc.Result asScala() { return new play.api.mvc.Result( header.asScala(), body.asScala(), session == null ? Scala.None() : Scala.Option(play.api.mvc.Session.fromJavaSession(session)), flash == null ? Scala.None() : Scala.Option(play.api.mvc.Flash.fromJavaFlash(flash)), JavaHelpers$.MODULE$.cookiesToScalaCookies(cookies) ); } }
/** * Extracts the Status code of this Result value. */ default int status() { return toScala().header().status(); }
/** * Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang. * * @param result the result where the lang will be set. * @param lang the lang to set on the result * @return a new result with the lang. */ public Result setLang(Result result, Lang lang) { return messages.setLang(result.asScala(), lang).asJava(); }
/** * Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang. * * @param result the result where the lang will be set. * @param lang the lang to set on the result * @return a new result with the lang. */ public Result setLang(Result result, Lang lang) { return messages.setLang(result.asScala(), lang).asJava(); }
/** * Given a Result, return a new Result with the lang cookie discarded. * * @param result the result to clear the lang. * @return a new result with a cleared lang. */ public Result clearLang(Result result) { return messages.clearLang(result.asScala()).asJava(); }
/** * Given a Result, return a new Result with the lang cookie discarded. * * @param result the result to clear the lang. * @return a new result with a cleared lang. */ public Result clearLang(Result result) { return messages.clearLang(result.asScala()).asJava(); }
/** * Given a Result, return a new Result with the lang cookie discarded. * * @param result the result to clear the lang. * @return a new result with a cleared lang. */ public Result clearLang(Result result) { return messages.clearLang(result.asScala()).asJava(); }
/** * Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang. * * @param result the result where the lang will be set. * @param lang the lang to set on the result * @return a new result with the lang. */ public Result setLang(Result result, Lang lang) { return messages.setLang(result.asScala(), lang).asJava(); }
static <A, B> Accumulator<ByteString, F.Either<Result, A>> delegate(play.api.mvc.BodyParser<B> delegate, Function<B, A> transform, Http.RequestHeader request) { Accumulator<ByteString, scala.util.Either<play.api.mvc.Result, B>> javaAccumulator = delegate.apply(request.asScala()).asJava(); return javaAccumulator.map(result -> { if (result.isLeft()) { return F.Either.Left(result.left().get().asJava()); } else { return F.Either.Right(transform.apply(result.right().get())); } }, JavaParsers.trampoline()); } }
static <A, B> Accumulator<ByteString, F.Either<Result, A>> delegate(play.api.mvc.BodyParser<B> delegate, Function<B, A> transform, Http.RequestHeader request) { Accumulator<ByteString, scala.util.Either<play.api.mvc.Result, B>> javaAccumulator = delegate.apply(request.asScala()).asJava(); return javaAccumulator.map(result -> { if (result.isLeft()) { return F.Either.Left(result.left().get().asJava()); } else { return F.Either.Right(transform.apply(result.right().get())); } }, JavaParsers.trampoline()); } }