Package com.glitchybyte.glib.function
Interface GFunctionWithException<T,R>
- Type Parameters:
T- Type of argument of the function.R- Type of result of the function.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a function that takes one argument and can throw an exception.
-
Method Summary
Modifier and TypeMethodDescriptionApplies the function.static <T,R> R applyOrDefault(GFunctionWithException<T, R> function, T arg, R defaultValue) Get value from function or default if there is an exception.static <T,R> R applyOrNull(GFunctionWithException<T, R> function, T arg) Get value from function or null if there is an exception.
-
Method Details
-
apply
Applies the function.- Parameters:
arg- Function argument.- Returns:
- A result.
- Throws:
Exception- Some exception.
-
applyOrDefault
Get value from function or default if there is an exception.- Type Parameters:
T- Type of argument.R- Type of return value.- Parameters:
function- Function.arg- Argument for function.defaultValue- Default value if there is an exception.- Returns:
- Value from function or default if there is an exception.
-
applyOrNull
Get value from function or null if there is an exception.- Type Parameters:
T- Type of argument.R- Type of return value.- Parameters:
function- Function.arg- Argument for function.- Returns:
- Value from function or null if there is an exception.
-