本文整理汇总了Java中io.vavr.control.Try.get方法的典型用法代码示例。如果您正苦于以下问题:Java Try.get方法的具体用法?Java Try.get怎么用?Java Try.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vavr.control.Try
的用法示例。
在下文中一共展示了Try.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDataRemoveRow
import io.vavr.control.Try; //导入方法依赖的package包/类
@Test
public void testDataRemoveRow() {
DataTable table = createDataTable();
// Remove row at row index 2.
Try<DataTable> result = table.rows().remove(2);
assertTrue(result.isSuccess());
DataTable newTable = result.get();
assertTrue(newTable.rowCount() == 3);
assertTrue(newTable.column("StrCol").valueAt(0) == "AA");
assertTrue(newTable.column("StrCol").valueAt(1) == "BB");
assertTrue(newTable.column("StrCol").valueAt(2) == "DD");
assertTrue((int)newTable.column("IntCol").valueAt(0) == 3);
assertTrue((int)newTable.column("IntCol").valueAt(1) == 5);
assertTrue((int)newTable.column("IntCol").valueAt(2) == 11);
assertTrue((boolean)newTable.column("BoolCol").valueAt(0));
assertTrue(!(boolean)newTable.column("BoolCol").valueAt(1));
assertTrue(!(boolean)newTable.column("BoolCol").valueAt(2));
}
示例2: safeClone
import io.vavr.control.Try; //导入方法依赖的package包/类
default Self safeClone(Try<Object> lambdaThatCallsClone) {
try {
return (Self) lambdaThatCallsClone.get();
} catch(Throwable e) {
throw new RuntimeException(e);
}
}
示例3: registerAccessToken
import io.vavr.control.Try; //导入方法依赖的package包/类
public Optional<AccessToken> registerAccessToken(final RequestToken requestToken, final String pinCode) {
log.info("Registering token {} with pincode {}", requestToken.toString(), pinCode);
final Try<AccessToken> tryAccessToken = Try.of(() -> {
// Don't refactor expression lambda into statement lambda. It's too
// long to be treated that way.
//noinspection CodeBlock2Expr
return this.twitter.getOAuthAccessToken(requestToken, pinCode);
});
if (tryAccessToken.isFailure()) {
log.info("Could not get access token! An error was thrown!");
return Optional.empty();
}
final AccessToken successAccessToken = tryAccessToken.get();
this.twitter.setOAuthAccessToken(successAccessToken);
log.info(
"Successfully got access token for user @{}! {}",
successAccessToken.getScreenName(),
successAccessToken.toString()
);
this.accessToken = successAccessToken;
this.sessionManager.addNewSession(this);
return Optional.of(successAccessToken);
}
示例4: assertSuccessAndGet
import io.vavr.control.Try; //导入方法依赖的package包/类
private <T extends Node> T assertSuccessAndGet(final Try<T> loadResult) {
assertThat(loadResult.isSuccess()).isTrue();
return loadResult.get();
}
示例5: getRootScene
import io.vavr.control.Try; //导入方法依赖的package包/类
private Scene getRootScene(final EasyFxml easyFxml) {
final Try<Pane> rootPane = easyFxml
.loadNode(Views.ROOT_VIEW)
.recover(err -> new ExceptionHandler(err).asPane());
return new Scene(rootPane.get());
}