Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public record Result<T, E>(boolean isSuccess, T successValue, E failureValue) {
- private Result {
- // Private constructor
- }
- // Static method to create a Result instance representing success
- public static <T, E> Result<T, E> success(T value) {
- return new Result<>(true, value, null);
- }
- // Static method to create a Result instance representing failure
- public static <T, E> Result<T, E> failure(E value) {
- return new Result<>(false, null, value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement