Class SmartSupplier<T>

java.lang.Object
net.minheur.potoflux.utils.SmartSupplier<T>
Type Parameters:
T - type of value stored in the supplier
All Implemented Interfaces:
Supplier<T>

public class SmartSupplier<T> extends Object implements Supplier<T>
The smart supplier is a Supplier that don't recreate the field each time.
Once the value is created from the supplier once, it is stored in value and given each time get() is used
  • Constructor Details

    • SmartSupplier

      public SmartSupplier(Supplier<T> supplier)
      Creates the smart supplier from a simple one
      Parameters:
      supplier - initially storing the data
  • Method Details

    • get

      public T get()
      Gets the value. If value is null, creates it from the supplier
      Specified by:
      get in interface Supplier<T>
      Returns:
      value