Class LazyProperty<T>

java.lang.Object
dev.prozilla.pine.common.property.VariableProperty<T>
dev.prozilla.pine.common.property.LazyProperty<T>
Direct Known Subclasses:
SystemProperty

public abstract class LazyProperty<T> extends VariableProperty<T>
A property that does not have a value until it is used for the first time.

This type of property is optimized, because the value will only be fetched once in most cases. This is especially useful for values that are expensive to fetch.

  • Field Details

    • value

      protected T value
  • Constructor Details

    • LazyProperty

      public LazyProperty()
  • Method Details

    • fetch

      protected abstract T fetch()
    • getValue

      public T getValue()
      Returns the current value, or fetches the value if it is null.
      Specified by:
      getValue in class VariableProperty<T>
      Returns:
      The value of this property.