From a3a95154666eb0fbae948173d13ad72c5509b1c4 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 29 Feb 2016 09:05:36 -0500 Subject: Factored interface out of GenHolder --- .../src/main/java/bjc/utils/data/IHolder.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java new file mode 100644 index 0000000..aa7d5bd --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java @@ -0,0 +1,45 @@ +package bjc.utils.data; + +import java.util.function.Function; + +/** + * Generic interface for things that store a single value in a roughly + * monadic fashion + * + * @author ben + * + * @param + * The type of data being stored + */ +public interface IHolder { + + /** + * Return the result of applying the given transformation to the held + * value Doesn't change the held value + * + * @param f + * The transformation to apply + * @return A holder with the transformed value + */ + IHolder map(Function f); + + /** + * Apply the given transformation to the held value. Returns the holder + * for allowing chaining of transforms + * + * @param f + * The transform to apply to the value + * @return The holder + */ + IHolder transform(Function f); + + /** + * Returns a raw mapped value, not contained in a GenHolder + * + * @param f + * The function to use for mapping the value + * @return The mapped value outside of a GenHolder + */ + E unwrap(Function f); + +} \ No newline at end of file -- cgit v1.2.3