From eee86f6e7e148fae897a333ab0ca9b44584c264c Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Sat, 21 Nov 2020 11:00:31 -0500 Subject: Add static factory method to IHolder This gives you an easy way to produce an IHolder, without having to explicitly construct an instance of Identity --- src/main/java/bjc/data/IHolder.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/bjc/data/IHolder.java b/src/main/java/bjc/data/IHolder.java index faa3f64..e0d39aa 100644 --- a/src/main/java/bjc/data/IHolder.java +++ b/src/main/java/bjc/data/IHolder.java @@ -161,4 +161,17 @@ public interface IHolder extends Functor { */ public UnwrappedType unwrap(Function unwrapper); + + /** + * Create an instace of IHolder containing a single value. + * + * @param The type of the value contained. + * + * @param contained The value to contain. + * + * @return An instance of IHolder containing that value. + */ + static IHolder of(ElementType contained) { + return new Identity<>(contained); + } } -- cgit v1.2.3