Class NullProperty<T>

java.lang.Object
dev.prozilla.pine.common.property.fixed.NullProperty<T>
All Implemented Interfaces:
FixedProperty<T>, Property<T>, Functor<T>

public class NullProperty<T> extends Object implements FixedProperty<T>
A property whose value is always null.
  • Constructor Details

    • NullProperty

      public NullProperty()
  • Method Details

    • getValueOr

      @Contract("null -> fail; !null -> param1") public T getValueOr(T defaultValue)
      Returns the defaultValue, because the value of this property is always null.
      Specified by:
      getValueOr in interface Property<T>
      Parameters:
      defaultValue - The value to return
      Returns:
      The defaultValue.
    • getValue

      @Contract("-> null") public T getValue()
      Returns null.
      Specified by:
      getValue in interface Property<T>
      Returns:
      null
    • isNotNull

      @Contract("-> false") public boolean isNotNull()
      Returns false, because the value of this property is always null.
      Specified by:
      isNotNull in interface Property<T>
      Returns:
      false
    • snapshot

      @Contract("-> this") public NullProperty<T> snapshot()
      Description copied from interface: FixedProperty
      Returns this property, because its value is always the same, so it is effectively the same as a snapshot.
      Specified by:
      snapshot in interface FixedProperty<T>
      Specified by:
      snapshot in interface Property<T>
      Returns:
      This property.
    • replaceNull

      public FixedColorProperty replaceNull(Color defaultValue)
    • replaceNull

      public FixedStringProperty replaceNull(String defaultValue)
    • replaceNull

      public FixedObjectProperty<T> replaceNull(T defaultValue)
      Description copied from interface: Property
      Returns a property whose value is the value of this property, or defaultValue if the value of this property is null.
      Specified by:
      replaceNull in interface FixedProperty<T>
      Specified by:
      replaceNull in interface Property<T>
      Returns:
      A property whose value is never null.