Tidy up checkstyle violations
This commit is contained in:
parent
684cdc06ae
commit
1f986139bc
5 changed files with 8 additions and 6 deletions
|
@ -38,13 +38,14 @@ import java.util.stream.Stream;
|
||||||
* @param <T> the type of the content
|
* @param <T> the type of the content
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("methodcount")
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
final class Just<T> implements Maybe<T> {
|
final class Just<T> implements Maybe<T> {
|
||||||
|
|
||||||
private final T value;
|
private final T value;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R> Maybe<R> flatMap(Function<T, Maybe<R>> f) {
|
public <R> Maybe<R> flatMap(final Function<T, Maybe<R>> f) {
|
||||||
return f.apply(value);
|
return f.apply(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ final class Just<T> implements Maybe<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
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
|
@Override
|
||||||
|
@ -70,7 +71,7 @@ final class Just<T> implements Maybe<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T orElse(final T otherValue) {
|
public T orElse(final T otherValue) {
|
||||||
return this.value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,7 +39,7 @@ final class Nothing<T> implements Maybe<T> {
|
||||||
static final Maybe<?> INSTANCE = new Nothing<>();
|
static final Maybe<?> INSTANCE = new Nothing<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R> Maybe<R> flatMap(Function<T, Maybe<R>> f) {
|
public <R> Maybe<R> flatMap(final Function<T, Maybe<R>> f) {
|
||||||
return Maybe.nothing();
|
return Maybe.nothing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Err<T> implements Result<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(final Object other) {
|
||||||
return other instanceof Err && Objects.equals(error, ((Err) other).error);
|
return other instanceof Err && Objects.equals(error, ((Err) other).error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Success<T> implements Result<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(final Object other) {
|
||||||
return other instanceof Success && Objects.equals(value, ((Success) other).value);
|
return other instanceof Success && Objects.equals(value, ((Success) other).value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class ResultTest implements WithAssertions {
|
||||||
assertThat(Result.ok(1)).isNotEqualTo(Result.error(runtimeException));
|
assertThat(Result.ok(1)).isNotEqualTo(Result.error(runtimeException));
|
||||||
assertThat(Result.error(runtimeException)).isEqualTo(Result.error(runtimeException));
|
assertThat(Result.error(runtimeException)).isEqualTo(Result.error(runtimeException));
|
||||||
assertThat(Result.ok(1).equals("1")).isFalse();
|
assertThat(Result.ok(1).equals("1")).isFalse();
|
||||||
|
assertThat(Result.error(new RuntimeException()).equals("1")).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue