Package de.marcely.bedwars.tools
Class LazyReference<T>
java.lang.Object
de.marcely.bedwars.tools.LazyReference<T>
- Type Parameters:
- T- The type of the reference
- All Implemented Interfaces:
- Supplier<T>
Represents a lazy reference that will only be initialized when it's being accessed.
 
After the initial access, the reference will be cached and returned on every subsequent access.
- 
Constructor SummaryConstructors
- 
Method Summary
- 
Constructor Details- 
LazyReferenceCreates a new lazy reference.- Parameters:
- factory- The factory that will be called when the reference is being accessed
 
 
- 
- 
Method Details- 
getGets the reference.- Specified by:
- getin interface- Supplier<T>
- Returns:
- The reference
- Throws:
- IllegalStateException- If the factory returns null
 
- 
clearpublic void clear()Clears the cached reference.
- 
ofCreates a new lazy reference.- Type Parameters:
- T- The type of the reference
- Parameters:
- factory- The factory that will be called when the reference is being accessed
- Returns:
- The new lazy reference
 
 
-