本文整理汇总了Java中javaslang.control.Try.run方法的典型用法代码示例。如果您正苦于以下问题:Java Try.run方法的具体用法?Java Try.run怎么用?Java Try.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javaslang.control.Try
的用法示例。
在下文中一共展示了Try.run方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: takeScreenshot
import javaslang.control.Try; //导入方法依赖的package包/类
public static void takeScreenshot(final WebDriver driver) {
final WebDriver augmentedDriver = new Augmenter().augment(driver);
final File screenshot = ((TakesScreenshot) augmentedDriver).
getScreenshotAs(OutputType.FILE);
Try.run(() -> FileUtils.copyFile(screenshot,
new File("screen" + RandomStringUtils.randomNumeric(3) + ".png")));
}
示例2: waitUntil
import javaslang.control.Try; //导入方法依赖的package包/类
/**
* Frequently checking if something happened by testing a condition.
* If after {@link #WAIT_COUNT} * {@link #WAIT_MILLIS} ms nothing happened, an {@code AssertionError} is thrown.
*
* @param condition A condition.
*/
static void waitUntil(Supplier<Boolean> condition) {
int count = 0;
while (!condition.get()) {
if (++count > WAIT_COUNT) {
fail("Condition not met.");
} else {
Try.run(() -> Thread.sleep(WAIT_MILLIS));
}
}
}
示例3: setUp
import javaslang.control.Try; //导入方法依赖的package包/类
@BeforeSuite
public void setUp() {
Try.run(() -> poolService = new ConcurrentLinkedPool<>(getUsersFactory(),
MIN_POOL_SIZE, MAX_POOL_SIZE, IS_POOL_FAIR, new ClientUsersListener()));
}
示例4: zZz
import javaslang.control.Try; //导入方法依赖的package包/类
/**
* Block current thread a random time between 0 and {@link #SLEEP_MAX_MILLIS} ms.
*/
static void zZz() {
Try.run(() -> Thread.sleep(RND.nextInt(SLEEP_MAX_MILLIS)));
}