java.lang.Object
it.tidalwave.util.LazySupplier<T>
- All Implemented Interfaces:
Supplier<T>
A supplier of an object that is lazily evaluated (when its value is requested for the first time). It warranties
that the real wrapped supplier is called only once.
- Since:
- 3.2-ALPHA-13
- Author:
- Fabrizio Giudici
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the supplier.get()peek()Returns the value without computing it: unlikeget(), this method never calls the wrapped supplier, so it can be used to find out whether the value is available without the side effects of computing it.voidChanges the reference.toString()
-
Constructor Details
-
LazySupplier
public LazySupplier()
-
-
Method Details
-
get
-
peek
Returns the value without computing it: unlikeget(), this method never calls the wrapped supplier, so it can be used to find out whether the value is available without the side effects of computing it. The returnedOptionalcontains the value if it has been computed and is not null.- Returns:
- the value, if available, or an empty
Optional - Since:
- 5.0-ALPHA-4
-
clear
public void clear()Clears the supplier. -
set
Changes the reference.- Parameters:
ref- the new reference
-
toString
-