Class LazyValue<T>
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.LazyValue<T>
-
- All Implemented Interfaces:
Supplier<T>
public abstract class LazyValue<T> extends Object implements Supplier<T>
An instances of this class represents a lazy value of typeT.LazyValueimplements an evaluate by need semantics:createValue()is called exactly once whenget()is called for the first time.LazyValueinstances are thread safe.
-
-
Constructor Summary
Constructors Constructor Description LazyValue()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TcreateValue()Factory method called to create the value on an as need basis.Tget()Get value.booleanhasValue()
-
-
-
Method Detail
-
createValue
protected abstract T createValue()
Factory method called to create the value on an as need basis.- Returns:
- a new instance for
T.
-
hasValue
public boolean hasValue()
- Returns:
trueiffget()has been called at least once.
-
get
public T get()
Get value. CallscreateValue()if called for the first time.
-
-