Package me.hsgamer.hscore.common
Class CachedValue<T>
java.lang.Object
me.hsgamer.hscore.common.CachedValue<T>
- Type Parameters:
T- the type of the value
- All Implemented Interfaces:
Supplier<T>
The base class for caching value
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the cached valueabstract Tgenerate()Generate the valueget()getValue()Get the cached value or generate one if the cache is nullstatic <T> CachedValue<T> Create a new cached value from a supplier
-
Constructor Details
-
CachedValue
public CachedValue()
-
-
Method Details
-
of
Create a new cached value from a supplier- Type Parameters:
T- the type of the value- Parameters:
supplier- the supplier- Returns:
- the cached value
-
getValue
Get the cached value or generate one if the cache is null- Returns:
- the value
-
clearCache
public void clearCache()Clear the cached value -
generate
Generate the value- Returns:
- the value
-
get
-