From f51f6da7319787348c38b875652b5c0e9f88c8aa Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:43:13 -0400 Subject: Cleanup pass Pass to do some cleanups --- src/main/java/bjc/data/IHolder.java | 55 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/main/java/bjc/data/IHolder.java') diff --git a/src/main/java/bjc/data/IHolder.java b/src/main/java/bjc/data/IHolder.java index e56e23e..faa3f64 100644 --- a/src/main/java/bjc/data/IHolder.java +++ b/src/main/java/bjc/data/IHolder.java @@ -16,27 +16,28 @@ import bjc.funcdata.theory.Functor; * @author ben * * @param - * The type of value held. + * The type of value held. */ public interface IHolder extends Functor { /** * Bind a function across the value in this container. * * @param - * The type of value in this container. + * The type of value in this container. * * @param binder - * The function to bind to the value. + * The function to bind to the value. * * @return A holder from binding the value. */ - public IHolder bind(Function> binder); + public IHolder + bind(Function> binder); /** * Apply an action to the value. * * @param action - * The action to apply to the value. + * The action to apply to the value. */ public default void doWith(final Consumer action) { transform(value -> { @@ -47,11 +48,12 @@ public interface IHolder extends Functor { } @Override - default Function, Functor> fmap( - final Function func) { + default Function, Functor> + fmap(final Function func) { return argumentFunctor -> { - if(!(argumentFunctor instanceof IHolder)) { - final String msg = "This functor only supports mapping over instances of IHolder"; + if (!(argumentFunctor instanceof IHolder)) { + final String msg + = "This functor only supports mapping over instances of IHolder"; throw new IllegalArgumentException(msg); } @@ -71,14 +73,15 @@ public interface IHolder extends Functor { * Lifts a function to bind over this holder. * * @param - * The type of the functions return. + * The type of the functions return. * * @param func - * The function to lift over the holder. + * The function to lift over the holder. * * @return The function lifted over the holder. */ - public Function> lift(Function func); + public Function> + lift(Function func); /** * Make this holder lazy. @@ -108,56 +111,54 @@ public interface IHolder extends Functor { } /** - * Create a new holder with a mapped version of the value in this - * holder. + * Create a new holder with a mapped version of the value in this holder. * * Does not change the internal state of this holder. * * @param - * The type of the mapped value. + * The type of the mapped value. * * @param mapper - * The function to do mapping with. + * The function to do mapping with. * * @return A holder with the mapped value */ - public IHolder map(Function mapper); + public IHolder + map(Function mapper); /** * Replace the held value with a new one. * * @param newValue - * The value to hold instead. + * The value to hold instead. * * @return The holder itself. */ public default IHolder replace(final ContainedType newValue) { - return transform(oldValue -> { - return newValue; - }); + return transform(oldValue -> newValue); } /** * Transform the value held in this holder. * * @param transformer - * The function to transform the value with. + * The function to transform the value with. * * @return The holder itself, for easy chaining. */ public IHolder transform(UnaryOperator transformer); /** - * Unwrap the value contained in this holder so that it is no longer - * held. + * Unwrap the value contained in this holder so that it is no longer held. * * @param - * The type of the unwrapped value. + * The type of the unwrapped value. * * @param unwrapper - * The function to use to unwrap the value. + * The function to use to unwrap the value. * * @return The unwrapped held value. */ - public UnwrappedType unwrap(Function unwrapper); + public UnwrappedType + unwrap(Function unwrapper); } -- cgit v1.2.3