diff options
Diffstat (limited to 'src/main/java/org/pacien/lemonad/attempt/Success.java')
-rw-r--r-- | src/main/java/org/pacien/lemonad/attempt/Success.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/org/pacien/lemonad/attempt/Success.java b/src/main/java/org/pacien/lemonad/attempt/Success.java new file mode 100644 index 0000000..928fbb1 --- /dev/null +++ b/src/main/java/org/pacien/lemonad/attempt/Success.java | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * lemonad - Some functional sweetness for Java | ||
3 | * Copyright (C) 2019 Pacien TRAN-GIRARD | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU Affero General Public License as | ||
7 | * published by the Free Software Foundation, either version 3 of the | ||
8 | * License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | package org.pacien.lemonad.attempt; | ||
20 | |||
21 | import java.util.NoSuchElementException; | ||
22 | |||
23 | import lombok.Value; | ||
24 | |||
25 | /** | ||
26 | * @author pacien | ||
27 | */ | ||
28 | @Value class Success<R, E> implements Attempt<R, E> { | ||
29 | R result; | ||
30 | |||
31 | @Override public boolean isSuccess() { | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | @Override public boolean isFailure() { | ||
36 | return false; | ||
37 | } | ||
38 | |||
39 | @Override public E getError() { | ||
40 | throw new NoSuchElementException(); | ||
41 | } | ||
42 | } | ||