diff options
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java | 18 |
1 files changed, 16 insertions, 2 deletions
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 index 2767897..7d1d7a0 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IHolder.java @@ -15,8 +15,11 @@ import java.util.function.UnaryOperator; public interface IHolder<ContainedType> { /** * Bind a function across the value in this container - * @param <BoundType> The type of value in this container - * @param binder The function to bind to the value + * + * @param <BoundType> + * The type of value in this container + * @param binder + * The function to bind to the value * @return A holder from binding the value */ public <BoundType> IHolder<BoundType> bind( @@ -82,4 +85,15 @@ public interface IHolder<ContainedType> { */ public <UnwrappedType> UnwrappedType unwrap( Function<ContainedType, UnwrappedType> unwrapper); + + /** + * Replace the held value with a new one + * + * @param newValue + * The value to hold instead + * @return The holder itself + */ + public default IHolder<ContainedType> replace(ContainedType newValue) { + return transform((oldValue) -> newValue); + } } |
