From 77fcc58d1facffbc3af50be8c05985350e9f1355 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Sun, 17 Apr 2016 15:01:44 -0400 Subject: Code maintenace and changes --- .../java/bjc/utils/data/experimental/IHolder.java | 101 --------------------- 1 file changed, 101 deletions(-) delete mode 100644 BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java deleted file mode 100644 index 6ccf115..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java +++ /dev/null @@ -1,101 +0,0 @@ -package bjc.utils.data.experimental; - -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.UnaryOperator; - -/** - * A holder of a single value. - * - * @author ben - * - * @param - * The type of value held - */ -public interface IHolder { - /** - * Bind a function across the value in this container - * - * @param - * The type of value in this container - * @param binder - * 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 - * - * @param action - * The action to apply to the value - */ - public default void doWith(Consumer action) { - transform((value) -> { - action.accept(value); - - return value; - }); - } - - /** - * Get the value contained in this holder without changing it. - * - * @return The value held in this holder - */ - public default ContainedType getValue() { - return unwrap((value) -> value); - } - - /** - * 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 - * @param mapper - * The function to do mapping with - * @return A holder with the mapped value - */ - public IHolder map( - Function mapper); - - /** - * Transform the value held in this holder - * - * @param transformer - * 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 - * - * @param - * The type of the unwrapped value - * @param unwrapper - * The function to use to unwrap the value - * @return The unwrapped held value - */ - public UnwrappedType unwrap( - Function unwrapper); - - /** - * Replace the held value with a new one - * - * @param newValue - * The value to hold instead - * @return The holder itself - */ - public default IHolder replace(ContainedType newValue) { - return transform((oldValue) -> { - return newValue; - }); - } -} -- cgit v1.2.3