Advertisement
SimpleCookie

Untitled

Mar 19th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public record Result<T>(boolean isSuccess, T value) {
  2.     private Result {
  3.         // Private constructor
  4.     }
  5.  
  6.     // Static method to create a Result instance representing success
  7.     public static <T> Result<T> success(T value) {
  8.         return new Result<>(true, value);
  9.     }
  10.  
  11.     // Static method to create a Result instance representing failure
  12.     public static <T> Result<T> failure() {
  13.         return new Result<>(false, null);
  14.     }
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement