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


Java Try.failure方法代码示例

本文整理汇总了Java中io.vavr.control.Try.failure方法的典型用法代码示例。如果您正苦于以下问题:Java Try.failure方法的具体用法?Java Try.failure怎么用?Java Try.failure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vavr.control.Try的用法示例。


在下文中一共展示了Try.failure方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tryGetAs

import io.vavr.control.Try; //导入方法依赖的package包/类
/**
 * Returns the value of a particular row column as a specific type.
 * This method performs bounds checks and type checks. Any errors
 * will return a Try.failure.
 *
 * @param type The data type.
 * @param idx The index of the column.
 * @param <T> The value type.
 * @return Returns the value at the specified index.
 */
public <T> Try<T> tryGetAs(Class<T> type, Integer idx) {

    // Get the column as it's typed version.
    Try<DataColumn<T>> col = this.table.columns()
            .tryGet(idx)
            .flatMap(c -> c.asType(type));

    return col.isFailure()
            ? Try.failure(col.getCause())
            : Try.success(col.get().valueAt(this.rowIdx));
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:22,代码来源:DataRow.java

示例2: value

import io.vavr.control.Try; //导入方法依赖的package包/类
@Override
public final Try<T> value() {
    List<Try<X>> outcomes = results.map(Result::value);
    if (!outcomes.filter(Try::isFailure).isEmpty()) {
        return Try.failure(
                new RuntimeException(
                        String.join("\r\n", issues())
                )
        );
    }
    return Try.success(
        outcomes.map(Try::get).transform(transformFunction)
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:15,代码来源:RTransformed.java

示例3: value

import io.vavr.control.Try; //导入方法依赖的package包/类
@Override
public final Try<T> value() {
    return Try.failure(
        new RuntimeException(
            String.join("\r\n", issues)
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:9,代码来源:RFailure.java

示例4: columnToValue

import io.vavr.control.Try; //导入方法依赖的package包/类
private Try<Object> columnToValue(Try<IDataColumn> column) {
    return column.isSuccess()
            ? Try.success(column.get().valueAt(this.rowIdx))
            : Try.failure(column.getCause());
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:6,代码来源:DataRow.java

示例5: tryCast

import io.vavr.control.Try; //导入方法依赖的package包/类
/**
 * Used to perform a type check and cast on an object instance.
 * Returns a Try success or failure depending on if it was valid cast.
 *
 * @param <T> The type to return.
 * @param type The type to cast to.
 * @param obj The object to cast.
 * @return Returns a Success<T> or a Failure.
 */
@SuppressWarnings({"unchecked"})
static <T> Try<T> tryCast(Class<T> type, Object obj) {
    return type.isInstance(obj)
            ? Try.success((T)obj)
            : Try.failure(new DataTableException("Invalid cast."));
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:16,代码来源:GenericExtensions.java

示例6: tryNotNull

import io.vavr.control.Try; //导入方法依赖的package包/类
/**
 * Asserts the argument is not null. Returns in a Try.
 *
 * @param <T> The argument type.
 * @param argument The argument to check.
 * @param name The name of the argument.
 * @return Returns a Try testing the argument being null.
 */
public static <T> Try<T> tryNotNull(T argument, String name) {
    return argument == null
            ? Try.failure(new IllegalArgumentException("Invalid value [NULL] for argument " + name))
            : Try.success(argument);
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:14,代码来源:Guard.java

示例7: tryError

import io.vavr.control.Try; //导入方法依赖的package包/类
/**
 * Creates a DataTableException wrapped in a Try.
 *
 * @param errorMessage The error message.
 * @param <T> The Try type.
 * @return Returns a new DataTable Exception in a try.
 */
public static <T> Try<T> tryError(String errorMessage) {
    return Try.failure(new DataTableException(errorMessage));
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:11,代码来源:DataTableException.java


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