play.libs.Scala.asScalaWithFuture()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中play.libs.Scala.asScalaWithFuture()方法的一些代码示例,展示了Scala.asScalaWithFuture()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scala.asScalaWithFuture()方法的具体详情如下:
包路径:play.libs.Scala
类名称:Scala
方法名:asScalaWithFuture

Scala.asScalaWithFuture介绍

[英]Converts a Java Callable to a Scala Function0.
[中]将可调用的Java转换为Scala函数0。

代码示例

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * An alias for futures(stage, delay, unit) that uses a java.time.Duration.
 *
 * @param stage the input completion stage that may time out.
 * @param duration The duration after which there is a timeout.
 * @param <A> the completion stage that should be wrapped with a future.
 * @return the completion stage, or a completion stage that failed with futures.
 */
@Override
public <A> CompletionStage<A> timeout(final CompletionStage<A> stage, final Duration duration) {
  requireNonNull(stage, "Null stage");
  requireNonNull(duration, "Null duration");
  FiniteDuration finiteDuration = FiniteDuration.apply(duration.toMillis(), TimeUnit.MILLISECONDS);
  return toJava(delegate.timeout(finiteDuration, Scala.asScalaWithFuture(() -> stage)));
}

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * Create a CompletionStage which, after a delay, will be redeemed with the result of a
 * given supplier. The supplier will be called after the delay.
 *
 * @param callable the input completion stage that is delayed.
 * @param duration to wait.
 * @param <A> the type of the completion's result.
 * @return the delayed CompletionStage wrapping supplier.
 */
@Override
public <A> CompletionStage<A> delayed(final Callable<CompletionStage<A>> callable, Duration duration) {
  requireNonNull(callable, "Null callable");
  requireNonNull(duration, "Null duration");
  FiniteDuration finiteDuration = FiniteDuration.apply(duration.toMillis(), TimeUnit.MILLISECONDS);
  return toJava(delegate.delayed(finiteDuration, Scala.asScalaWithFuture(callable)));
}

代码示例来源:origin: com.typesafe.play/play

/**
 * An alias for futures(stage, delay, unit) that uses a java.time.Duration.
 *
 * @param stage the input completion stage that may time out.
 * @param duration The duration after which there is a timeout.
 * @param <A> the completion stage that should be wrapped with a future.
 * @return the completion stage, or a completion stage that failed with futures.
 */
@Override
public <A> CompletionStage<A> timeout(final CompletionStage<A> stage, final Duration duration) {
  requireNonNull(stage, "Null stage");
  requireNonNull(duration, "Null duration");
  FiniteDuration finiteDuration = FiniteDuration.apply(duration.toMillis(), TimeUnit.MILLISECONDS);
  return toJava(delegate.timeout(finiteDuration, Scala.asScalaWithFuture(() -> stage)));
}

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * An alias for futures(stage, delay, unit) that uses a java.time.Duration.
 *
 * @param stage the input completion stage that may time out.
 * @param duration The duration after which there is a timeout.
 * @param <A> the completion stage that should be wrapped with a future.
 * @return the completion stage, or a completion stage that failed with futures.
 */
@Override
public <A> CompletionStage<A> timeout(final CompletionStage<A> stage, final Duration duration) {
  requireNonNull(stage, "Null stage");
  requireNonNull(duration, "Null duration");
  FiniteDuration finiteDuration = FiniteDuration.apply(duration.toMillis(), TimeUnit.MILLISECONDS);
  return toJava(delegate.timeout(finiteDuration, Scala.asScalaWithFuture(() -> stage)));
}

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * Create a CompletionStage which, after a delay, will be redeemed with the result of a
 * given supplier. The supplier will be called after the delay.
 *
 * @param callable the input completion stage that is delayed.
 * @param duration to wait.
 * @param <A> the type of the completion's result.
 * @return the delayed CompletionStage wrapping supplier.
 */
@Override
public <A> CompletionStage<A> delayed(final Callable<CompletionStage<A>> callable, Duration duration) {
  requireNonNull(callable, "Null callable");
  requireNonNull(duration, "Null duration");
  FiniteDuration finiteDuration = FiniteDuration.apply(duration.toMillis(), TimeUnit.MILLISECONDS);
  return toJava(delegate.delayed(finiteDuration, Scala.asScalaWithFuture(callable)));
}

代码示例来源:origin: com.typesafe.play/play

/**
 * Create a CompletionStage which, after a delay, will be redeemed with the result of a
 * given supplier. The supplier will be called after the delay.
 *
 * @param callable the input completion stage that is delayed.
 * @param duration to wait.
 * @param <A> the type of the completion's result.
 * @return the delayed CompletionStage wrapping supplier.
 */
@Override
public <A> CompletionStage<A> delayed(final Callable<CompletionStage<A>> callable, Duration duration) {
  requireNonNull(callable, "Null callable");
  requireNonNull(duration, "Null duration");
  FiniteDuration finiteDuration = FiniteDuration.apply(duration.toMillis(), TimeUnit.MILLISECONDS);
  return toJava(delegate.delayed(finiteDuration, Scala.asScalaWithFuture(callable)));
}

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * Create a CompletionStage which, after a delay, will be redeemed with the result of a
 * given supplier. The supplier will be called after the delay.
 *
 * @param callable the input completion stage that is delayed.
 * @param amount The time to wait.
 * @param unit The units to use for the amount.
 * @param <A> the type of the completion's result.
 * @return the delayed CompletionStage wrapping supplier.
 */
@Override
public <A> CompletionStage<A> delayed(final Callable<CompletionStage<A>> callable, long amount, TimeUnit unit) {
  requireNonNull(callable, "Null callable");
  requireNonNull(amount, "Null amount");
  requireNonNull(unit, "Null unit");
  FiniteDuration duration = FiniteDuration.apply(amount, unit);
  return toJava(delegate.delayed(duration, Scala.asScalaWithFuture(callable)));
}

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * Create a CompletionStage which, after a delay, will be redeemed with the result of a
 * given supplier. The supplier will be called after the delay.
 *
 * @param callable the input completion stage that is delayed.
 * @param amount The time to wait.
 * @param unit The units to use for the amount.
 * @param <A> the type of the completion's result.
 * @return the delayed CompletionStage wrapping supplier.
 */
@Override
public <A> CompletionStage<A> delayed(final Callable<CompletionStage<A>> callable, long amount, TimeUnit unit) {
  requireNonNull(callable, "Null callable");
  requireNonNull(amount, "Null amount");
  requireNonNull(unit, "Null unit");
  FiniteDuration duration = FiniteDuration.apply(amount, unit);
  return toJava(delegate.delayed(duration, Scala.asScalaWithFuture(callable)));
}

代码示例来源:origin: com.typesafe.play/play

/**
 * Create a CompletionStage which, after a delay, will be redeemed with the result of a
 * given supplier. The supplier will be called after the delay.
 *
 * @param callable the input completion stage that is delayed.
 * @param amount The time to wait.
 * @param unit The units to use for the amount.
 * @param <A> the type of the completion's result.
 * @return the delayed CompletionStage wrapping supplier.
 */
@Override
public <A> CompletionStage<A> delayed(final Callable<CompletionStage<A>> callable, long amount, TimeUnit unit) {
  requireNonNull(callable, "Null callable");
  requireNonNull(amount, "Null amount");
  requireNonNull(unit, "Null unit");
  FiniteDuration duration = FiniteDuration.apply(amount, unit);
  return toJava(delegate.delayed(duration, Scala.asScalaWithFuture(callable)));
}

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * Creates a CompletionStage that returns either the input stage, or a futures.
 *
 * Note that timeout is not the same as cancellation.  Even in case of futures,
 * the given completion stage will still complete, even though that completed value
 * is not returned.
 *
 * @param stage the input completion stage that may time out.
 * @param amount The amount (expressed with the corresponding unit).
 * @param unit The time Unit.
 * @param <A> the completion's result type.
 * @return either the completed future, or a completion stage that failed with futures.
 */
@Override
public <A> CompletionStage<A> timeout(final CompletionStage<A> stage, final long amount, final TimeUnit unit) {
  requireNonNull(stage, "Null stage");
  requireNonNull(unit, "Null unit");
  FiniteDuration duration = FiniteDuration.apply(amount, unit);
  return toJava(delegate.timeout(duration, Scala.asScalaWithFuture(() -> stage)));
}

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * Creates a CompletionStage that returns either the input stage, or a futures.
 *
 * Note that timeout is not the same as cancellation.  Even in case of futures,
 * the given completion stage will still complete, even though that completed value
 * is not returned.
 *
 * @param stage the input completion stage that may time out.
 * @param amount The amount (expressed with the corresponding unit).
 * @param unit The time Unit.
 * @param <A> the completion's result type.
 * @return either the completed future, or a completion stage that failed with futures.
 */
@Override
public <A> CompletionStage<A> timeout(final CompletionStage<A> stage, final long amount, final TimeUnit unit) {
  requireNonNull(stage, "Null stage");
  requireNonNull(unit, "Null unit");
  FiniteDuration duration = FiniteDuration.apply(amount, unit);
  return toJava(delegate.timeout(duration, Scala.asScalaWithFuture(() -> stage)));
}

代码示例来源:origin: com.typesafe.play/play

/**
 * Creates a CompletionStage that returns either the input stage, or a futures.
 *
 * Note that timeout is not the same as cancellation.  Even in case of futures,
 * the given completion stage will still complete, even though that completed value
 * is not returned.
 *
 * @param stage the input completion stage that may time out.
 * @param amount The amount (expressed with the corresponding unit).
 * @param unit The time Unit.
 * @param <A> the completion's result type.
 * @return either the completed future, or a completion stage that failed with futures.
 */
@Override
public <A> CompletionStage<A> timeout(final CompletionStage<A> stage, final long amount, final TimeUnit unit) {
  requireNonNull(stage, "Null stage");
  requireNonNull(unit, "Null unit");
  FiniteDuration duration = FiniteDuration.apply(amount, unit);
  return toJava(delegate.timeout(duration, Scala.asScalaWithFuture(() -> stage)));
}

代码示例来源:origin: com.typesafe.play/play-cache_2.11

@Override
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration) {
  return toJava(
    asyncCacheApi.getOrElseUpdate(key, intToDuration(expiration), Scala.asScalaWithFuture(block), Scala.<T>classTag()));
}

代码示例来源:origin: com.typesafe.play/play-cache

@Override
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration) {
  return toJava(
    asyncCacheApi.getOrElseUpdate(key, intToDuration(expiration), Scala.asScalaWithFuture(block), Scala.<T>classTag()));
}

代码示例来源:origin: com.typesafe.play/play-cache_2.12

@Override
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration) {
  return toJava(
    asyncCacheApi.getOrElseUpdate(key, intToDuration(expiration), Scala.asScalaWithFuture(block), Scala.<T>classTag()));
}

代码示例来源:origin: com.typesafe.play/play-cache_2.12

@Override
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block) {
  return toJava(asyncCacheApi.getOrElseUpdate(key, Duration.Inf(), Scala.asScalaWithFuture(block), Scala.<T>classTag()));
}

代码示例来源:origin: com.typesafe.play/play-cache_2.11

@Override
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block) {
  return toJava(asyncCacheApi.getOrElseUpdate(key, Duration.Inf(), Scala.asScalaWithFuture(block), Scala.<T>classTag()));
}

代码示例来源:origin: com.typesafe.play/play-cache

@Override
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block) {
  return toJava(asyncCacheApi.getOrElseUpdate(key, Duration.Inf(), Scala.asScalaWithFuture(block), Scala.<T>classTag()));
}

相关文章