New method #isSet() in Lazy and LazyOrException class

This commit is contained in:
Marc Baloup 2023-08-27 01:48:09 +02:00
parent 84298b08b3
commit 463a4d7e78
2 changed files with 18 additions and 0 deletions

View File

@ -56,4 +56,13 @@ public class Lazy<T> implements Supplier<T> {
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;
}
}

View File

@ -58,4 +58,13 @@ public class LazyOrException<T, E extends Exception> 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;
}
}