Result is a Java library for modeling operation outcomes explicitly. It gives you a simpler, faster alternative to exception-driven flow when you want to represent both success and failure in a single, composable type.
Why Result?
Optional is great for values that may be present or absent, but it does not explain why something is missing. Result fills that gap by carrying either a successful value or a failure reason, so your code can describe what happened instead of hiding it.
Quick Start
1
Create a result from an operation
2
Inspect whether it succeeded or failed
3
Transform it if needed, then unwrap it as required
Latest Releases
Available in
Add-Ons
Integrate Result with popular libraries.
Demo Projects
Try it for yourself in 5 minutes.
Features
Ready to Tap into the Power of Results?
Read the guide and transform your error handling today.
Also available as an ebook in multiple formats.
TL;DR
Not a fan of reading long docs? No worries! Tune in to Deep Dive, a podcast generated by . In just a few minutes, you'll get the essential details and a fun intro to what this library can do for you!
Result<User, Exception> result = Results.ofCallable(() -> db.getUser(id));
result.ifFailure(error -> logger.error("Couldn't get user: {}", id, error));
String name = result.mapSuccess(User::name).orElse("Anonymous");