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

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

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

Scala.orNull介绍

[英]Wraps a Scala Option, handling None as null.
[中]包装Scala选项,将None处理为null。

代码示例

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

@Deprecated
public static Result route(Application app, RequestBuilder requestBuilder, byte[] body, long timeout) {
 return wrapScalaResult(Scala.orNull(play.api.test.Helpers.jRoute(app.getWrappedApplication(), requestBuilder.build()._underlyingRequest(), body)), timeout);
}

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

@SuppressWarnings("unchecked")
public static Result route(Application app, RequestBuilder requestBuilder, long timeout) {
 final scala.Option<scala.concurrent.Future<play.api.mvc.Result>> opt = play.api.test.Helpers.jRoute(
   app.getWrappedApplication(), requestBuilder.build()._underlyingRequest(), requestBuilder.bodyAsAnyContent());
 return wrapScalaResult(Scala.orNull(opt), timeout);
}

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

/**
 * Route the request considering the given timeout.
 *
 * @param app The application used while routing and executing the request
 * @param requestBuilder the request builder
 * @param timeout the amount of time, in milliseconds, to wait for the body to be produced.
 * @return the result
 */
@SuppressWarnings("unchecked")
public static Result route(Application app, RequestBuilder requestBuilder, long timeout) {
  final scala.Option<scala.concurrent.Future<play.api.mvc.Result>> opt = play.api.test.Helpers.jRoute(
      app.asScala(),
      requestBuilder.build().asScala(),
      requestBuilder.body()
  );
  return wrapScalaResult(Scala.orNull(opt), timeout);
}

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

/**
 * Route the request considering the given timeout.
 *
 * @param app The application used while routing and executing the request
 * @param requestBuilder the request builder
 * @param timeout the amount of time, in milliseconds, to wait for the body to be produced.
 * @return the result
 */
@SuppressWarnings("unchecked")
public static Result route(Application app, RequestBuilder requestBuilder, long timeout) {
  final scala.Option<scala.concurrent.Future<play.api.mvc.Result>> opt = play.api.test.Helpers.jRoute(
      app.asScala(),
      requestBuilder.build().asScala(),
      requestBuilder.body()
  );
  return wrapScalaResult(Scala.orNull(opt), timeout);
}

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

/**
 * Retrieves a resource stream from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return InputStream to the resource (may be null)
 */
public InputStream resourceAsStream(String relativePath) {
  return Scala.orNull(env.resourceAsStream(relativePath));
}

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

/**
 * Retrieves a configuration value as a <code>Milliseconds</code>.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public Long getMilliseconds(String key) {
  return (Long)Scala.orNull(conf.getMilliseconds(key));
}

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

/**
 * Retrieves a configuration value as a {@code List<Integer>}.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public List<Integer> getIntList(String key) {
  return (List<Integer>)Scala.orNull(conf.getIntList(key));
}

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

/**
 * Retrieves a resource stream from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return InputStream to the resource (may be null)
 */
public InputStream resourceAsStream(String relativePath) {
  return Scala.orNull(env.resourceAsStream(relativePath));
}

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

/**
 * Retrieves a resource from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return URL to the resource (may be null)
 */
public URL resource(String relativePath) {
  return Scala.orNull(env.resource(relativePath));
}

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

/**
 * Retrieves a configuration value as an <code>Double</code>.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public Double getDouble(String key) {
  return (Double)Scala.orNull(conf.getDouble(key));
}

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

/**
 * Retrieves a configuration value as a {@code List<Long>}.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public List<Long> getLongList(String key) {
  return (List<Long>)Scala.orNull(conf.getLongList(key));
}

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

/**
 * Retrieves a resource stream from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return InputStream to the resource (may be null)
 */
public InputStream resourceAsStream(String relativePath) {
  return Scala.orNull(env.resourceAsStream(relativePath));
}

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

/**
 * Retrieves a resource from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return URL to the resource (may be null)
 */
public URL resource(String relativePath) {
  return Scala.orNull(env.resource(relativePath));
}

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

/**
 * Retrieves a configuration value as a <code>Bytes</code>.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public Long getBytes(String key) {
  return (Long)Scala.orNull(conf.getBytes(key));
}

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

/**
 * Retrieves a configuration value as a <code>Boolean</code>.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public Boolean getBoolean(String key) {
  return (Boolean)Scala.orNull(conf.getBoolean(key));
}

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

/**
 * Retrieves a configuration value as a {@code List<Long>} representing Milliseconds.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public List<Long> getMillisecondsList(String key) {
  return (List<Long>)Scala.orNull(conf.getMillisecondsList(key));
}

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

protected HttpErrorHandler preferred(Http.RequestHeader request) {
  String preferredContentType = Scala.orNull(MediaRange.preferred(
      Scala.toSeq(request.acceptedTypes()),
      Scala.toSeq(errorHandlerMap.keySet().toArray(new String[]{}))
  ));
  if (preferredContentType == null) {
    return errorHandlerMap.values().iterator().next();
  } else {
    return errorHandlerMap.get(preferredContentType);
  }
}

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

/**
 * Retrieves a configuration value as a <code>String</code>.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */
public String getString(String key) {
  return Scala.orNull(conf.getString(key, scala.Option.<scala.collection.immutable.Set<java.lang.String>>empty()));
}

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

/**
 * Get a resource from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return URL to the resource (may be null)
 */
default URL resource(String relativePath) {
  return Scala.orNull(getWrappedApplication().resource(relativePath));
}

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

public Status(play.api.mvc.Results.Status status, File content, int chunkSize) {
  if(content == null) {
    throw new NullPointerException("null content");
  }
  wrappedResult = status.chunked(
      play.core.j.JavaResults.chunked(content, chunkSize),
      play.core.j.JavaResults.writeBytes(Scala.orNull(play.api.libs.MimeTypes.forFileName(content.getName())))
  );
}

相关文章