Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Getters
- public class Result<T, E> {
- private final boolean isSuccess;
- private final T successValue;
- private final E failureValue;
- // Private constructor
- private Result(boolean isSuccess, T successValue, E failureValue) {
- this.isSuccess = isSuccess;
- this.successValue = successValue;
- this.failureValue = failureValue;
- }
- public static <T, E> Result<T, E> success(T value) {
- return new Result<>(true, value, null);
- }
- 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