Package aQute.bnd.memoize
Class ReferenceMemoizingSupplier<T>
- java.lang.Object
-
- aQute.bnd.memoize.ReferenceMemoizingSupplier<T>
-
- All Implemented Interfaces:
Memoize<T>
,java.util.function.Supplier<T>
class ReferenceMemoizingSupplier<T> extends java.lang.Object implements Memoize<T>
The object can exist in one of two states:- cleared which means memoized holds a cleared reference. This is the initial state. The object transitions to this state if the garbage collector clears the reference. From this state, the object transitions to valued when @{code get} is called.
- valued which means memoized holds a reference with a value.
-
-
Constructor Summary
Constructors Constructor Description ReferenceMemoizingSupplier(java.util.function.Supplier<? extends T> supplier, java.util.function.Function<? super T,? extends java.lang.ref.Reference<? extends T>> reference)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
Get the memoized value.boolean
isPresent()
If a value is memoized, returntrue
.T
peek()
Peek the memoized value, if any.java.lang.String
toString()
-
-
-
Method Detail
-
peek
public T peek()
Description copied from interface:Memoize
Peek the memoized value, if any.This method will not result in a call to the source supplier.
-
isPresent
public boolean isPresent()
Description copied from interface:Memoize
If a value is memoized, returntrue
. Otherwise returnfalse
.This method will not result in a call to the source supplier.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-