Package com.leakyabstractions.result.core
Result Library for Java
Creating Results
There are several ways to create result objects.
Successful Results
A successful result contains a non-null value produced by an operation when everything works as intended.
Failed Results
On the other hand, a failed result holds a value representing the problem that prevented the operation from completing.
Results Based on Nullable Values
When we need to create results that depend on a possibly null value. If the first argument is null, then the
second one will be used to create a failed result. The second argument can be either a failure value or a function
that produces a failure value.
Results Based on Optionals
We can also create results that depend on an Optional value. If the first argument is an
empty optional, then the second one will be used to create a failed result. The second argument can be a
Supplier too.
Results Based on Callables
Finally, if we have a task that may either return a success value or throw an exception, we can encapsulate it as a result so we don't need to use a try-catch block.
- Author:
- Guillermo Calvo
- See Also: