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); }