diff options
Diffstat (limited to 'src/main/java/org/pacien/lemonad/attempt/Failure.java')
-rw-r--r-- | src/main/java/org/pacien/lemonad/attempt/Failure.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/org/pacien/lemonad/attempt/Failure.java b/src/main/java/org/pacien/lemonad/attempt/Failure.java new file mode 100644 index 0000000..752e981 --- /dev/null +++ b/src/main/java/org/pacien/lemonad/attempt/Failure.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 Failure<R, E> implements Attempt<R, E> { | ||
29 | E error; | ||
30 | |||
31 | @Override public boolean isSuccess() { | ||
32 | return false; | ||
33 | } | ||
34 | |||
35 | @Override public boolean isFailure() { | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | @Override public R getResult() { | ||
40 | throw new NoSuchElementException(); | ||
41 | } | ||
42 | } | ||