From f26c5f07d5168a13085646b137178435e06d44a5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 29 Sep 2018 19:16:27 +0100 Subject: [PATCH] Bump kemitix-checkstyle-ruleset from 4.1.1 to 5.0.0 --- pom.xml | 2 +- src/main/java/net/kemitix/mon/Functor.java | 2 +- .../net/kemitix/mon/combinator/After.java | 4 +- .../net/kemitix/mon/combinator/Around.java | 8 ++-- .../net/kemitix/mon/combinator/Before.java | 4 +- .../mon/experimental/either/Either.java | 14 +++---- .../java/net/kemitix/mon/maybe/Maybe.java | 34 ++++++++-------- .../java/net/kemitix/mon/result/Result.java | 40 +++++++++---------- .../mon/result/WithResultContinuation.java | 4 +- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/pom.xml b/pom.xml index 1279036..906cf3c 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ 2.12 1.2.0 net.kemitix.mon - 4.1.1 + 5.0.0 diff --git a/src/main/java/net/kemitix/mon/Functor.java b/src/main/java/net/kemitix/mon/Functor.java index 7dc4fa1..acd8a06 100644 --- a/src/main/java/net/kemitix/mon/Functor.java +++ b/src/main/java/net/kemitix/mon/Functor.java @@ -48,5 +48,5 @@ public interface Functor> { * * @return a Functor containing the result of the function {@code f} applied to the value */ - F map(Function f); + public abstract F map(Function f); } diff --git a/src/main/java/net/kemitix/mon/combinator/After.java b/src/main/java/net/kemitix/mon/combinator/After.java index 3fd00c4..783a98f 100644 --- a/src/main/java/net/kemitix/mon/combinator/After.java +++ b/src/main/java/net/kemitix/mon/combinator/After.java @@ -52,7 +52,7 @@ public interface After extends * @return a partially applied Function that will take an argument and return the result of applying it to the * function parameter */ - static Function decorate( + public static Function decorate( final Function function, final BiConsumer after ) { @@ -68,7 +68,7 @@ public interface After extends * * @return a curried function that will pass the argument and the result of the function to the supplied bi-consumer */ - static After create() { + public static After create() { return function -> after -> argument -> { final R result = function.apply(argument); after.accept(argument, result); diff --git a/src/main/java/net/kemitix/mon/combinator/Around.java b/src/main/java/net/kemitix/mon/combinator/Around.java index b6d8e2e..8adcae1 100644 --- a/src/main/java/net/kemitix/mon/combinator/Around.java +++ b/src/main/java/net/kemitix/mon/combinator/Around.java @@ -54,7 +54,7 @@ public interface Around extends * * @return a partially applied Function that will take an argument, and the result of applying it to function */ - static Function decorate( + public static Function decorate( final Function function, final BiConsumer, T> around ) { @@ -71,7 +71,7 @@ public interface Around extends * @return a curried function that will execute the around function, passing an executable and the invocations * argument. The around function must {@code execute()} the executable and may capture the result. */ - static Around create() { + public static Around create() { return function -> around -> argument -> { final AtomicReference result = new AtomicReference<>(); final Executable callback = () -> { @@ -89,13 +89,13 @@ public interface Around extends * @param the return type of the function */ @FunctionalInterface - interface Executable { + public static interface Executable { /** * Executes the function. * * @return the result of applying the function */ - R execute(); + public abstract R execute(); } } diff --git a/src/main/java/net/kemitix/mon/combinator/Before.java b/src/main/java/net/kemitix/mon/combinator/Before.java index 4e40a29..5bbe5bd 100644 --- a/src/main/java/net/kemitix/mon/combinator/Before.java +++ b/src/main/java/net/kemitix/mon/combinator/Before.java @@ -53,7 +53,7 @@ public interface Before extends * @return a partially applied Function that will take an argument and return the result of applying it to the * function parameter */ - static Function decorate( + public static Function decorate( final Consumer before, final Function function ) { @@ -69,7 +69,7 @@ public interface Before extends * * @return a curried function that will pass the argument to before applying the supplied function */ - static Before create() { + public static Before create() { return before -> function -> argument -> { before.accept(argument); return function.apply(argument); diff --git a/src/main/java/net/kemitix/mon/experimental/either/Either.java b/src/main/java/net/kemitix/mon/experimental/either/Either.java index 90aa272..78de86e 100644 --- a/src/main/java/net/kemitix/mon/experimental/either/Either.java +++ b/src/main/java/net/kemitix/mon/experimental/either/Either.java @@ -41,7 +41,7 @@ public interface Either { * @param the type of the right value * @return a Either holding the left value */ - static Either left(final L l) { + public static Either left(final L l) { return new Left<>(l); } @@ -53,7 +53,7 @@ public interface Either { * @param the type of the right value * @return a Either holding the right value */ - static Either right(final R r) { + public static Either right(final R r) { return new Right<>(r); } @@ -62,14 +62,14 @@ public interface Either { * * @return true if this Either is a left */ - boolean isLeft(); + public abstract boolean isLeft(); /** * Checks if the Either holds a right value. * * @return true if this Either is a right */ - boolean isRight(); + public abstract boolean isRight(); /** * Matches the Either, invoking the correct Consumer. @@ -77,7 +77,7 @@ public interface Either { * @param onLeft the Consumer to invoke when the Either is a left * @param onRight the Consumer to invoke when the Either is a right */ - void match(Consumer onLeft, Consumer onRight); + public abstract void match(Consumer onLeft, Consumer onRight); /** * Map the function across the left value. @@ -86,7 +86,7 @@ public interface Either { * @param the type to change the left value to * @return a new Either */ - Either mapLeft(Function f); + public abstract Either mapLeft(Function f); /** * Map the function across the right value. @@ -95,5 +95,5 @@ public interface Either { * @param the type to change the right value to * @return a new Either */ - Either mapRight(Function f); + public abstract Either mapRight(Function f); } diff --git a/src/main/java/net/kemitix/mon/maybe/Maybe.java b/src/main/java/net/kemitix/mon/maybe/Maybe.java index c862a32..43fd8cd 100644 --- a/src/main/java/net/kemitix/mon/maybe/Maybe.java +++ b/src/main/java/net/kemitix/mon/maybe/Maybe.java @@ -50,7 +50,7 @@ public interface Maybe extends Functor> { * @param the type of the value * @return a Maybe of the value */ - static Maybe just(@NonNull final T value) { + public static Maybe just(@NonNull final T value) { return new Just<>(value); } @@ -61,7 +61,7 @@ public interface Maybe extends Functor> { * @return an empty Maybe */ @SuppressWarnings("unchecked") - static Maybe nothing() { + public static Maybe nothing() { return (Maybe) Nothing.INSTANCE; } @@ -74,7 +74,7 @@ public interface Maybe extends Functor> { * @param the type of the value * @return a Maybe, either a Just, or Nothing if value is null */ - static Maybe maybe(final T value) { + public static Maybe maybe(final T value) { if (value == null) { return nothing(); } @@ -86,14 +86,14 @@ public interface Maybe extends Functor> { * * @return true if the Maybe is a Just */ - boolean isJust(); + public abstract boolean isJust(); /** * Checks if the Maybe is Nothing. * * @return true if the Maybe is Nothing */ - boolean isNothing(); + public abstract boolean isNothing(); /** * Monad binder maps the Maybe into another Maybe using the binder method f. @@ -102,10 +102,10 @@ public interface Maybe extends Functor> { * @param the type of the value in the final maybe * @return a Maybe with the mapped value */ - Maybe flatMap(Function> f); + public abstract Maybe flatMap(Function> f); @Override - Maybe map(Function f); + public abstract Maybe map(Function f); /** * Provide a value to use when Maybe is Nothing. @@ -113,7 +113,7 @@ public interface Maybe extends Functor> { * @param supplier supplier for an alternate value * @return a Maybe */ - T orElseGet(Supplier supplier); + public abstract T orElseGet(Supplier supplier); /** * A value to use when Maybe is Nothing. @@ -121,14 +121,14 @@ public interface Maybe extends Functor> { * @param otherValue an alternate value * @return the value of the Maybe if a Just, otherwise the otherValue */ - T orElse(T otherValue); + public abstract T orElse(T otherValue); /** * Convert the Maybe to an {@link Optional}. * * @return an Optional containing a value for a Just, or empty for a Nothing */ - Optional toOptional(); + public abstract Optional toOptional(); /** * Throw the exception if the Maybe is a Nothing. @@ -138,14 +138,14 @@ public interface Maybe extends Functor> { * @return the value of the Maybe if a Just * @throws X if the Maybe is nothing */ - T orElseThrow(Supplier e) throws X; + public abstract T orElseThrow(Supplier e) throws X; /** * Converts the Maybe into either a single value stream or an empty stream. * * @return a Stream containing the value or nothing. */ - Stream stream(); + public abstract Stream stream(); /** * Filter a Maybe by the predicate, replacing with Nothing when it fails. @@ -153,7 +153,7 @@ public interface Maybe extends Functor> { * @param predicate the test * @return the Maybe, or Nothing if the test returns false */ - Maybe filter(Predicate predicate); + public abstract Maybe filter(Predicate predicate); /** * Provide the value within the Maybe, if it exists, to the Consumer, and returns this Maybe. @@ -161,14 +161,14 @@ public interface Maybe extends Functor> { * @param consumer the Consumer to the value if present * @return this Maybe */ - Maybe peek(Consumer consumer); + public abstract Maybe peek(Consumer consumer); /** * Run the runnable if the Maybe is a Nothing, otherwise do nothing. * * @param runnable the runnable to call if this is a Nothing */ - void ifNothing(Runnable runnable); + public abstract void ifNothing(Runnable runnable); /** * Matches the Maybe, either just or nothing, and performs either the Consumer, for Just, or Runnable for nothing. @@ -176,7 +176,7 @@ public interface Maybe extends Functor> { * @param justMatcher the Consumer to pass the value of a Just to * @param nothingMatcher the Runnable to call if the Maybe is a Nothing */ - void match(Consumer justMatcher, Runnable nothingMatcher); + public abstract void match(Consumer justMatcher, Runnable nothingMatcher); /** * Maps the Maybe into another Maybe only when it is nothing. @@ -185,5 +185,5 @@ public interface Maybe extends Functor> { * * @return the original Maybe if not nothing, or the alternative */ - Maybe or(Supplier> alternative); + public abstract Maybe or(Supplier> alternative); } diff --git a/src/main/java/net/kemitix/mon/result/Result.java b/src/main/java/net/kemitix/mon/result/Result.java index c84a1ba..cef55c9 100644 --- a/src/main/java/net/kemitix/mon/result/Result.java +++ b/src/main/java/net/kemitix/mon/result/Result.java @@ -44,7 +44,7 @@ public interface Result extends Functor> { * @param the type of the Maybe and the Result * @return a Result containing the value of the Maybe when it is a Just, or the error when it is Nothing */ - static Result fromMaybe(final Maybe maybe, final Supplier error) { + public static Result fromMaybe(final Maybe maybe, final Supplier error) { return maybe.map(Result::ok) .orElseGet(() -> Result.error(error.get())); } @@ -56,7 +56,7 @@ public interface Result extends Functor> { * @param the type had the result been a success * @return an error Result */ - static Result error(final Throwable error) { + public static Result error(final Throwable error) { return new Err<>(error); } @@ -68,7 +68,7 @@ public interface Result extends Functor> { * @return a Result */ @SuppressWarnings("illegalcatch") - static Result of(final Callable callable) { + public static Result of(final Callable callable) { try { return Result.ok(callable.call()); } catch (final Exception e) { @@ -83,7 +83,7 @@ public interface Result extends Functor> { * @param the type of the value * @return a successful Result */ - static Result ok(final T value) { + public static Result ok(final T value) { return new Success<>(value); } @@ -97,7 +97,7 @@ public interface Result extends Functor> { * @return a Result containing the value of the Maybe when it is a Just, or the error when it is Nothing */ @SuppressWarnings("illegalcatch") - static Maybe toMaybe(final Result result) { + public static Maybe toMaybe(final Result result) { try { return Maybe.just(result.orElseThrow()); } catch (final Throwable throwable) { @@ -112,7 +112,7 @@ public interface Result extends Functor> { * @throws Throwable the result is an error */ @SuppressWarnings("illegalthrows") - T orElseThrow() throws Throwable; + public abstract T orElseThrow() throws Throwable; /** * Swaps the inner Result of a Maybe, so that a Result is on the outside. @@ -123,7 +123,7 @@ public interface Result extends Functor> { * original Maybe. If the original Maybe is Nothing, the Result will contain Nothing. If the original Result was an * error, then the Result will also be an error. */ - static Result> swap(final Maybe> maybeResult) { + public static Result> swap(final Maybe> maybeResult) { return maybeResult.orElseGet(() -> Result.ok(null)) .flatMap(value -> Result.ok(Maybe.maybe(value))); } @@ -135,7 +135,7 @@ public interface Result extends Functor> { * @param the type of the value withing the Result of the mapping function * @return a Result */ - Result flatMap(Function> f); + public abstract Result flatMap(Function> f); /** * Applies the function to the contents of a Maybe within the Result. @@ -146,7 +146,7 @@ public interface Result extends Functor> { * @param the type of the updated Result * @return a new Maybe within a Result */ - static Result> flatMapMaybe( + public static Result> flatMapMaybe( final Result> maybeResult, final Function, Result>> f ) { @@ -158,17 +158,17 @@ public interface Result extends Functor> { * * @return true if the Result is an error. */ - boolean isError(); + public abstract boolean isError(); /** * Checks if the Result is a success. * * @return true if the Result is a success. */ - boolean isOkay(); + public abstract boolean isOkay(); @Override - Result map(Function f); + public abstract Result map(Function f); /** * Matches the Result, either success or error, and supplies the appropriate Consumer with the value or error. @@ -176,7 +176,7 @@ public interface Result extends Functor> { * @param onSuccess the Consumer to pass the value of a successful Result to * @param onError the Consumer to pass the error from an error Result to */ - void match(Consumer onSuccess, Consumer onError); + public abstract void match(Consumer onSuccess, Consumer onError); /** * Wraps the value within the Result in a Maybe, either a Just if the predicate is true, or Nothing. @@ -184,7 +184,7 @@ public interface Result extends Functor> { * @param predicate the test to decide * @return a Result containing a Maybe that may or may not contain a value */ - Result> maybe(Predicate predicate); + public abstract Result> maybe(Predicate predicate); /** * Provide the value within the Result, if it is a success, to the Consumer, and returns this Result. @@ -192,7 +192,7 @@ public interface Result extends Functor> { * @param consumer the Consumer to the value if a success * @return this Result */ - Result peek(Consumer consumer); + public abstract Result peek(Consumer consumer); /** * Provide a way to attempt to recover from an error state. @@ -200,7 +200,7 @@ public interface Result extends Functor> { * @param f the function to recover from the error * @return a new Result, either a Success, or if recovery is not possible an other Err. */ - Result recover(Function> f); + public abstract Result recover(Function> f); /** * A handler for error states. @@ -210,7 +210,7 @@ public interface Result extends Functor> { * * @param errorConsumer the consumer to handle the error */ - void onError(Consumer errorConsumer); + public abstract void onError(Consumer errorConsumer); /** * Maps a Success Result to another Result using a Callable that is able to throw a checked exception. @@ -230,7 +230,7 @@ public interface Result extends Functor> { * @param the type of the final Result * @return a new Result */ - Result andThen(Function> f); + public abstract Result andThen(Function> f); /** * Perform the continuation with the current Result value then return the current Result, assuming there was no @@ -250,7 +250,7 @@ public interface Result extends Functor> { * @param f the function to map the Success value into the result continuation * @return the Result or a new error Result */ - Result thenWith(Function> f); + public abstract Result thenWith(Function> f); /** * Reduce two Results of the same type into one using the reducing function provided. @@ -262,5 +262,5 @@ public interface Result extends Functor> { * @param operator the function to combine the values the Results * @return a Result containing the combination of the two Results */ - Result reduce(Result identify, BinaryOperator operator); + public abstract Result reduce(Result identify, BinaryOperator operator); } diff --git a/src/main/java/net/kemitix/mon/result/WithResultContinuation.java b/src/main/java/net/kemitix/mon/result/WithResultContinuation.java index e20cc90..dea90c7 100644 --- a/src/main/java/net/kemitix/mon/result/WithResultContinuation.java +++ b/src/main/java/net/kemitix/mon/result/WithResultContinuation.java @@ -35,10 +35,10 @@ public interface WithResultContinuation { * * @throws Exception to replace the current Result with an error */ - void run() throws Exception; + public abstract void run() throws Exception; @SuppressWarnings({"illegalcatch", "javadocmethod"}) - default Result call(final Result currentResult) { + public default Result call(final Result currentResult) { try { run(); } catch (Throwable e) {