diff options
-rw-r--r-- | src/main/java/org/pacien/lemonad/attempt/Attempt.java | 2 | ||||
-rw-r--r-- | src/test/java/org/pacien/lemonad/attempt/AttemptTest.java | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/org/pacien/lemonad/attempt/Attempt.java b/src/main/java/org/pacien/lemonad/attempt/Attempt.java index fc437ad..e36ac4b 100644 --- a/src/main/java/org/pacien/lemonad/attempt/Attempt.java +++ b/src/main/java/org/pacien/lemonad/attempt/Attempt.java | |||
@@ -84,7 +84,7 @@ public interface Attempt<R, E> { | |||
84 | * @param mapper a function producing an {@link Attempt}, called with the current error if this {@link Attempt} is a failure. | 84 | * @param mapper a function producing an {@link Attempt}, called with the current error if this {@link Attempt} is a failure. |
85 | * @return this {@link Attempt} if it is a success, or the alternative {@link Attempt} retrieved from the supplier otherwise. | 85 | * @return this {@link Attempt} if it is a success, or the alternative {@link Attempt} retrieved from the supplier otherwise. |
86 | */ | 86 | */ |
87 | default <EE> Attempt<R, EE> mapFailure(@NonNull Function<? super E, ? extends Attempt<? extends R, ? extends EE>> mapper) { | 87 | default <EE> Attempt<R, EE> mapError(@NonNull Function<? super E, ? extends Attempt<? extends R, ? extends EE>> mapper) { |
88 | //noinspection unchecked | 88 | //noinspection unchecked |
89 | return (Attempt<R, EE>) (isFailure() ? mapper.apply(getError()) : this); | 89 | return (Attempt<R, EE>) (isFailure() ? mapper.apply(getError()) : this); |
90 | } | 90 | } |
diff --git a/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java b/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java index 1b165e8..6d87335 100644 --- a/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java +++ b/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java | |||
@@ -87,7 +87,7 @@ class AttemptTest { | |||
87 | var fault2 = 2; | 87 | var fault2 = 2; |
88 | 88 | ||
89 | Attempt.success(result0) | 89 | Attempt.success(result0) |
90 | .mapFailure(__ -> fail()) | 90 | .mapError(__ -> fail()) |
91 | .mapResult(res -> Attempt.success(result1)) | 91 | .mapResult(res -> Attempt.success(result1)) |
92 | .mapResult(res -> { | 92 | .mapResult(res -> { |
93 | assertEquals(result1, res); | 93 | assertEquals(result1, res); |
@@ -95,11 +95,11 @@ class AttemptTest { | |||
95 | }) | 95 | }) |
96 | .ifSuccess(__ -> fail()) | 96 | .ifSuccess(__ -> fail()) |
97 | .mapResult(__ -> fail()) | 97 | .mapResult(__ -> fail()) |
98 | .mapFailure(f -> { | 98 | .mapError(f -> { |
99 | assertEquals(fault0, f); | 99 | assertEquals(fault0, f); |
100 | return Attempt.failure(fault1); | 100 | return Attempt.failure(fault1); |
101 | }) | 101 | }) |
102 | .mapFailure(f -> { | 102 | .mapError(f -> { |
103 | assertEquals(fault1, f); | 103 | assertEquals(fault1, f); |
104 | return Attempt.success(result2); | 104 | return Attempt.success(result2); |
105 | }) | 105 | }) |