当前位置: 首页>>代码示例>>Java>>正文


Java Try.get方法代码示例

本文整理汇总了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));
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:25,代码来源:DataRowModificationTests.java

示例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);
    }
}
 
开发者ID:RedNifre,项目名称:ravr,代码行数:8,代码来源:Copyable.java

示例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);
}
 
开发者ID:Tristan971,项目名称:Lyrebird,代码行数:29,代码来源:TwitterHandler.java

示例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();
}
 
开发者ID:Tristan971,项目名称:EasyFXML,代码行数:5,代码来源:BaseEasyFxmlTest.java

示例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());
}
 
开发者ID:Tristan971,项目名称:Lyrebird,代码行数:7,代码来源:GuiBootstraper.java


注:本文中的io.vavr.control.Try.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。