Package aQute.bnd.memoize
Class MemoizingSupplier<T>
- java.lang.Object
-
- aQute.bnd.memoize.MemoizingSupplier<T>
-
- All Implemented Interfaces:
Memoize<T>,java.util.function.Supplier<T>
class MemoizingSupplier<T> extends java.lang.Object implements Memoize<T>
The object can exist in one of two states:- initial which means the source supplier has not been called or has not returned a value acceptable to the predicate and memoized holds the wrapped supplier. From this state, the object can transition to open.
- open which means memoized is the value from the source supplier. This is the terminal state.
-
-
Constructor Summary
Constructors Constructor Description MemoizingSupplier(java.util.function.Supplier<? extends T> supplier)MemoizingSupplier(java.util.function.Supplier<? extends T> supplier, java.util.function.Predicate<? super T> predicate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget()Get the memoized value.booleanisPresent()If a value is memoized, returntrue.Tpeek()Peek the memoized value, if any.java.lang.StringtoString()
-
-
-
Method Detail
-
peek
public T peek()
Description copied from interface:MemoizePeek 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:MemoizeIf 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:
toStringin classjava.lang.Object
-
-