Package com.yubico.yubikit.core.util
Class Result<T,E extends Throwable>
java.lang.Object
com.yubico.yubikit.core.util.Result<T,E>
- Type Parameters:
T
- the type of the wrapped valueE
- the type of the exception thrown
Result value, wrapping a T (if successful) or an Exception (if failed).
-
Method Summary
Modifier and TypeMethodDescriptionfailure
(E error) Constructs a Result for an Exception (failure).getValue()
Gets the held value, if the Result is successful, or throws the error on failure.boolean
isError()
Checks if the Result is a failure.boolean
Checks if the Result is successful.Runs the given callable, creating a Result of its value, if run successfully, or its Exception.success
(T value) Constructs a Result for a value (success).
-
Method Details
-
getValue
Gets the held value, if the Result is successful, or throws the error on failure.- Returns:
- the held value on success
- Throws:
E
- the held exception on failure
-
isSuccess
public boolean isSuccess()Checks if the Result is successful. -
isError
public boolean isError()Checks if the Result is a failure. -
success
Constructs a Result for a value (success).- Parameters:
value
- the value to hold
-
failure
Constructs a Result for an Exception (failure).- Parameters:
error
- the error to hold
-
of
Runs the given callable, creating a Result of its value, if run successfully, or its Exception.- Parameters:
call
- callable to invoke, resulting in a value
-