
org.smallibs.util.FunctionsWithError Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hpas Show documentation
Show all versions of hpas Show documentation
Functional ADT And Asynchronous library in Java
package org.smallibs.util;
import org.smallibs.data.Try;
import java.util.function.Function;
public interface FunctionsWithError {
static FunctionWithError fromFunction(Function function) {
return function::apply;
}
static Function> toFunction(FunctionWithError function) {
return t -> {
try {
return Try.success(function.apply(t));
} catch (Throwable throwable) {
return Try.failure(throwable);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy