From 946cab444bc301d8a7c756a1bab039558288de89 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Wed, 11 Oct 2017 13:41:07 -0300 Subject: Cleanup work --- base/src/main/java/bjc/utils/data/IHolder.java | 81 ++++++++++++++++---------- 1 file changed, 50 insertions(+), 31 deletions(-) (limited to 'base/src/main/java/bjc/utils/data/IHolder.java') diff --git a/base/src/main/java/bjc/utils/data/IHolder.java b/base/src/main/java/bjc/utils/data/IHolder.java index ca0b2ba..0b0cfd2 100644 --- a/base/src/main/java/bjc/utils/data/IHolder.java +++ b/base/src/main/java/bjc/utils/data/IHolder.java @@ -16,25 +16,28 @@ import bjc.utils.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 + * 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 - * @return A holder from binding the value + * The function to bind to the value. + * + * @return + * A holder from binding the value. */ public IHolder bind(Function> binder); /** - * Apply an action to the value + * 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 -> { @@ -66,38 +69,44 @@ public interface IHolder extends Functor { } /** - * Lifts a function to bind over this holder + * 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 - * @return The function lifted over the holder + * The function to lift over the holder. + * + * @return + * The function lifted over the holder. */ public Function> lift(Function func); /** - * Make this holder lazy + * Make this holder lazy. * - * @return A lazy version of this holder + * @return + * A lazy version of this holder. */ public default IHolder makeLazy() { return new WrappedLazy<>(this); } /** - * Make this holder a list + * Make this holder a list. * - * @return A list version of this holder + * @return + * A list version of this holder. */ public default IHolder makeList() { return new BoundListHolder<>(new FunctionalList<>(this)); } /** - * Make this holder optional + * Make this holder optional. * - * @return An optional version of this holder + * @return + * An optional version of this holder. */ public default IHolder makeOptional() { return new WrappedOption<>(this); @@ -107,22 +116,27 @@ public interface IHolder extends Functor { * Create a new holder with a mapped version of the value in this * holder. * - * Does not change the internal state of 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 - * @return A holder with the mapped value + * The function to do mapping with. + * + * @return + * A holder with the mapped value */ public IHolder map(Function mapper); /** - * Replace the held value with a new one + * Replace the held value with a new one. * * @param newValue - * The value to hold instead - * @return The holder itself + * The value to hold instead. + * + * @return + * The holder itself. */ public default IHolder replace(final ContainedType newValue) { return transform(oldValue -> { @@ -131,23 +145,28 @@ public interface IHolder extends Functor { } /** - * Transform the value held in this holder + * Transform the value held in this holder. * * @param transformer - * The function to transform the value with - * @return The holder itself, for easy chaining + * 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 + * held. * * @param - * The type of the unwrapped value + * The type of the unwrapped value. + * * @param unwrapper - * The function to use to unwrap the value - * @return The unwrapped held value + * The function to use to unwrap the value. + * + * @return + * The unwrapped held value. */ public UnwrappedType unwrap(Function unwrapper); } -- cgit v1.2.3