diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/Lazy.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/Lazy.java index 1d5d24e..4f33e8a 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/Lazy.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/Lazy.java @@ -56,4 +56,13 @@ public class Lazy implements Supplier { cached = true; } + /** + * Tells if the value is currently set or not. + * @return true if the value has been set by calling the method {@link #get()} or {@link #set(Object)} but not yet + * reset by {@link #reset()}, or false otherwise. + */ + public synchronized boolean isSet() { + return cached; + } + } diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/LazyOrException.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/LazyOrException.java index c3b5063..1dd1e45 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/LazyOrException.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/LazyOrException.java @@ -58,4 +58,13 @@ public class LazyOrException implements SupplierExceptio cached = true; } + /** + * Tells if the value is currently set or not. + * @return true if the value has been set by calling the method {@link #get()} or {@link #set(Object)} but not yet + * reset by {@link #reset()}, or false otherwise. + */ + public synchronized boolean isSet() { + return cached; + } + }