本文整理汇总了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));
}
示例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)
);
}
示例3: value
import io.vavr.control.Try; //导入方法依赖的package包/类
@Override
public final Try<T> value() {
return Try.failure(
new RuntimeException(
String.join("\r\n", issues)
)
);
}
示例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());
}
示例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."));
}
示例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);
}
示例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));
}