Interface SecpResult<T>
- Type Parameters:
T- type of the successful result
- All Known Implementing Classes:
SecpResult.Err, SecpResult.Ok
public interface SecpResult<T>
Functional-style result for secp256k1 -- either
SecpResult.Ok or SecpResult.Err.
If result is Ok the success result is in SecpResult.Ok.result(), if a failure
occurred the error code is in SecpResult.Err.code().-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classAn error result, with aninterror code inSecpResult.Err.code().static final classA successful result containing a value of type<T>inSecpResult.Ok.result(). -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SecpResult<T> Create a result from an error code and a supplier function.static <T> SecpResult<T> err(int error_code) Static constructor forSecpResult.Errdefault Tget()Get the result value or throw aRuntimeExceptiondefault TGet the result value or throw aRuntimeExceptionstatic <T> SecpResult<T> ok(T result) Static constructor forSecpResult.Ok
-
Method Details
-
ok
Static constructor forSecpResult.Ok- Type Parameters:
T- result type- Parameters:
result- result value- Returns:
- successful result
-
err
Static constructor forSecpResult.Err- Type Parameters:
T- expected result type- Parameters:
error_code- error code- Returns:
- error result
-
checked
Create a result from an error code and a supplier function. If the error code is1(no error), the supplier function is invoked to produce a successful result. Otherwise, an error result is returned containing the error code.- Type Parameters:
T- result value type- Parameters:
error_code- error codesupplier- value supplier- Returns:
- result
-
get
-
get
Get the result value or throw aRuntimeException- Parameters:
message- error message to include in exception- Returns:
- result value
-