本文整理了Java中scala.compat.java8.OptionConverters.toJava()
方法的一些代码示例,展示了OptionConverters.toJava()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OptionConverters.toJava()
方法的具体详情如下:
包路径:scala.compat.java8.OptionConverters
类名称:OptionConverters
方法名:toJava
暂无
代码示例来源:origin: com.typesafe.play/play-test_2.11
/**
* Executes a block of code in a running server, with a test browser.
*
* @param server the test server.
* @param webDriver the web driver instance.
* @param block the block of code to execute.
*/
public static void running(TestServer server, WebDriver webDriver, final Consumer<TestBrowser> block) {
Helpers$.MODULE$.runSynchronized(server.application(), asScala(() -> {
TestBrowser browser = null;
TestServer startedServer = null;
try {
start(server);
startedServer = server;
browser = testBrowser(webDriver, (Integer) OptionConverters.toJava(server.config().port()).get());
block.accept(browser);
} finally {
if (browser != null) {
browser.quit();
}
if (startedServer != null) {
stop(startedServer);
}
}
return null;
}));
}
代码示例来源:origin: com.typesafe.play/play-test_2.12
/**
* Executes a block of code in a running server, with a test browser.
*
* @param server the test server.
* @param webDriver the web driver instance.
* @param block the block of code to execute.
*/
public static void running(TestServer server, WebDriver webDriver, final Consumer<TestBrowser> block) {
Helpers$.MODULE$.runSynchronized(server.application(), asScala(() -> {
TestBrowser browser = null;
TestServer startedServer = null;
try {
start(server);
startedServer = server;
browser = testBrowser(webDriver, (Integer) OptionConverters.toJava(server.config().port()).get());
block.accept(browser);
} finally {
if (browser != null) {
browser.quit();
}
if (startedServer != null) {
stop(startedServer);
}
}
return null;
}));
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Retrieves a file relative to the application root path.
* This method returns an Optional, using empty if the file was not found.
*
* @param relativePath relative path of the file to fetch
* @return an existing file
*/
public Optional<File> getExistingFile(String relativePath) {
return OptionConverters.toJava(env.getExistingFile(relativePath));
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* @return The current transient language of this builder instance.
*/
Optional<Lang> transientLang() {
return OptionConverters.toJava(req.transientLang()).map(play.api.i18n.Lang::asJava);
}
}
代码示例来源:origin: com.typesafe.play/play
/**
* @return The current transient language of this builder instance.
*/
Optional<Lang> transientLang() {
return OptionConverters.toJava(req.transientLang()).map(play.api.i18n.Lang::asJava);
}
}
代码示例来源:origin: com.typesafe.play/play
/**
* Retrieves a file relative to the application root path.
* This method returns an Optional, using empty if the file was not found.
*
* @param relativePath relative path of the file to fetch
* @return an existing file
*/
public Optional<File> getExistingFile(String relativePath) {
return OptionConverters.toJava(env.getExistingFile(relativePath));
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* @return The current transient language of this builder instance.
*/
Optional<Lang> transientLang() {
return OptionConverters.toJava(req.transientLang()).map(play.api.i18n.Lang::asJava);
}
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Retrieves a file relative to the application root path.
* This method returns an Optional, using empty if the file was not found.
*
* @param relativePath relative path of the file to fetch
* @return an existing file
*/
public Optional<File> getExistingFile(String relativePath) {
return OptionConverters.toJava(env.getExistingFile(relativePath));
}
代码示例来源:origin: com.typesafe.play/play
/**
* If an application is loaded in dev mode then this additional context is available.
*
* @return optional with the value if the application is running in dev mode or empty otherwise.
*/
public Optional<play.api.ApplicationLoader.DevContext> devContext() {
return OptionConverters.toJava(underlying.devContext());
}
代码示例来源:origin: com.typesafe.play/play
/**
* Handle a request directly, without using the application.
* @param requestHeader the request made.
*
* @deprecated Deprecated as of 2.7.0. WebCommands are now handled by the DefaultHttpRequestHandler.
*/
@Deprecated
public Optional<Result> handleWebCommand(Http.RequestHeader requestHeader) {
return OptionConverters
.toJava(this.underlying.handleWebCommand(requestHeader.asScala()))
.map(play.api.mvc.Result::asJava);
}
}
代码示例来源:origin: com.typesafe.play/play
static Optional<LoggerConfigurator> apply(ClassLoader classLoader) {
return OptionConverters
.toJava(LoggerConfigurator$.MODULE$.apply(classLoader))
.map(loggerConfigurator -> {
if (loggerConfigurator instanceof LoggerConfigurator) {
return (LoggerConfigurator)loggerConfigurator;
} else {
// Avoid failing if using a Scala logger configurator
return new DelegateLoggerConfigurator(loggerConfigurator);
}
});
}
代码示例来源:origin: com.typesafe.play/play_2.11
static Optional<LoggerConfigurator> apply(ClassLoader classLoader) {
return OptionConverters
.toJava(LoggerConfigurator$.MODULE$.apply(classLoader))
.map(loggerConfigurator -> {
if (loggerConfigurator instanceof LoggerConfigurator) {
return (LoggerConfigurator)loggerConfigurator;
} else {
// Avoid failing if using a Scala logger configurator
return new DelegateLoggerConfigurator(loggerConfigurator);
}
});
}
代码示例来源:origin: com.typesafe.play/play_2.12
@Override
default void configure(scala.collection.immutable.Map<String, String> properties, Option<URL> config) {
configure(
Scala.asJava(properties),
OptionConverters.toJava(config)
);
}
代码示例来源:origin: com.typesafe.play/play_2.11
@Override
default void configure(scala.collection.immutable.Map<String, String> properties, Option<URL> config) {
configure(
Scala.asJava(properties),
OptionConverters.toJava(config)
);
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* @return the client X509Certificates if they have been set
*/
public Optional<List<X509Certificate>> clientCertificateChain() {
return OptionConverters.toJava(
req.connection().clientCertificateChain()).map(
list -> new ArrayList<>(Scala.asJava(list)));
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Get a value from the map, returning an empty {@link Optional} if it is not present.
*
* @param key The key for the value to retrieve.
* @param <A> The type of value to retrieve.
* @return An <code>Optional</code>, with the value present if it is in the map.
*/
public <A> Optional<A> getOptional(TypedKey<A> key) {
return OptionConverters.toJava(underlying.get(key.asScala()));
}
代码示例来源:origin: com.typesafe.play/play
/**
* Get a value from the map, returning an empty {@link Optional} if it is not present.
*
* @param key The key for the value to retrieve.
* @param <A> The type of value to retrieve.
* @return An <code>Optional</code>, with the value present if it is in the map.
*/
public <A> Optional<A> getOptional(TypedKey<A> key) {
return OptionConverters.toJava(underlying.get(key.asScala()));
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Get a value from the map, returning an empty {@link Optional} if it is not present.
*
* @param key The key for the value to retrieve.
* @param <A> The type of value to retrieve.
* @return An <code>Optional</code>, with the value present if it is in the map.
*/
public <A> Optional<A> getOptional(TypedKey<A> key) {
return OptionConverters.toJava(underlying.get(key.asScala()));
}
代码示例来源:origin: com.typesafe.play/play
private Http.MultipartFormData.FilePart<A> toJava(play.api.mvc.MultipartFormData.FilePart<A> filePart) {
return new Http.MultipartFormData.FilePart<>(
filePart.key(),
filePart.filename(),
OptionConverters.toJava(filePart.contentType()).orElse(null),
filePart.ref(),
filePart.fileSize(),
filePart.dispositionType()
);
}
代码示例来源:origin: com.typesafe.play/play_2.12
private Http.MultipartFormData.FilePart<A> toJava(play.api.mvc.MultipartFormData.FilePart<A> filePart) {
return new Http.MultipartFormData.FilePart<>(
filePart.key(),
filePart.filename(),
OptionConverters.toJava(filePart.contentType()).orElse(null),
filePart.ref(),
filePart.fileSize(),
filePart.dispositionType()
);
}
内容来源于网络,如有侵权,请联系作者删除!