Advertisement
SimpleCookie

Untitled

Mar 19th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. @Getters
  2. public class Result<T, E> {
  3.     private final boolean isSuccess;
  4.     private final T successValue;
  5.     private final E failureValue;
  6.  
  7.     // Private constructor
  8.     private Result(boolean isSuccess, T successValue, E failureValue) {
  9.         this.isSuccess = isSuccess;
  10.         this.successValue = successValue;
  11.         this.failureValue = failureValue;
  12.     }
  13.  
  14.     public static <T, E> Result<T, E> success(T value) {
  15.         return new Result<>(true, value, null);
  16.     }
  17.  
  18.     public static <T, E> Result<T, E> failure(E value) {
  19.         return new Result<>(false, null, value);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement