diff --git a/src/main/java/net/kemitix/mon/maybe/Just.java b/src/main/java/net/kemitix/mon/maybe/Just.java index f801bde..77a258f 100644 --- a/src/main/java/net/kemitix/mon/maybe/Just.java +++ b/src/main/java/net/kemitix/mon/maybe/Just.java @@ -38,13 +38,14 @@ import java.util.stream.Stream; * @param the type of the content * @author Paul Campbell (pcampbell@kemitix.net) */ +@SuppressWarnings("methodcount") @RequiredArgsConstructor(access = AccessLevel.PROTECTED) final class Just implements Maybe { private final T value; @Override - public Maybe flatMap(Function> f) { + public Maybe flatMap(final Function> f) { return f.apply(value); } @@ -55,7 +56,7 @@ final class Just implements Maybe { @Override public boolean equals(final Object other) { - return other instanceof Just && Objects.equals(this.value, ((Just) other).value); + return other instanceof Just && Objects.equals(value, ((Just) other).value); } @Override @@ -70,7 +71,7 @@ final class Just implements Maybe { @Override public T orElse(final T otherValue) { - return this.value; + return value; } @Override diff --git a/src/main/java/net/kemitix/mon/maybe/Nothing.java b/src/main/java/net/kemitix/mon/maybe/Nothing.java index 7a72d46..05f033d 100644 --- a/src/main/java/net/kemitix/mon/maybe/Nothing.java +++ b/src/main/java/net/kemitix/mon/maybe/Nothing.java @@ -39,7 +39,7 @@ final class Nothing implements Maybe { static final Maybe INSTANCE = new Nothing<>(); @Override - public Maybe flatMap(Function> f) { + public Maybe flatMap(final Function> f) { return Maybe.nothing(); } diff --git a/src/main/java/net/kemitix/mon/result/Err.java b/src/main/java/net/kemitix/mon/result/Err.java index d0c4cb4..e197dea 100644 --- a/src/main/java/net/kemitix/mon/result/Err.java +++ b/src/main/java/net/kemitix/mon/result/Err.java @@ -75,7 +75,7 @@ class Err implements Result { } @Override - public boolean equals(Object other) { + public boolean equals(final Object other) { return other instanceof Err && Objects.equals(error, ((Err) other).error); } diff --git a/src/main/java/net/kemitix/mon/result/Success.java b/src/main/java/net/kemitix/mon/result/Success.java index 9093b08..ec2aa58 100644 --- a/src/main/java/net/kemitix/mon/result/Success.java +++ b/src/main/java/net/kemitix/mon/result/Success.java @@ -78,7 +78,7 @@ class Success implements Result { } @Override - public boolean equals(Object other) { + public boolean equals(final Object other) { return other instanceof Success && Objects.equals(value, ((Success) other).value); } diff --git a/src/test/java/net/kemitix/mon/ResultTest.java b/src/test/java/net/kemitix/mon/ResultTest.java index 5e56fca..1386251 100644 --- a/src/test/java/net/kemitix/mon/ResultTest.java +++ b/src/test/java/net/kemitix/mon/ResultTest.java @@ -16,6 +16,7 @@ public class ResultTest implements WithAssertions { assertThat(Result.ok(1)).isNotEqualTo(Result.error(runtimeException)); assertThat(Result.error(runtimeException)).isEqualTo(Result.error(runtimeException)); assertThat(Result.ok(1).equals("1")).isFalse(); + assertThat(Result.error(new RuntimeException()).equals("1")).isFalse(); } @Test