Class VariableProperty<T>

java.lang.Object
dev.prozilla.pine.common.property.VariableProperty<T>
Type Parameters:
T - The type of property
Direct Known Subclasses:
AdaptivePropertyBase, AnimatedProperty, ConditionalProperty, FixedProperty, LazyProperty, MutableProperty, RandomProperty, StyledProperty, SuppliedProperty, VariableAnimatedProperty, VariableColorProperty

public abstract class VariableProperty<T> extends Object
A property with a value that may change in certain circumstances.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final Random
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this property has any value.
    abstract T
    Returns the value of this property.
    static <T> T
    Returns the value of a given property, or null if the property is null.
    static <T> T
    getValue(VariableProperty<T> property, T defaultValue)
    Returns the value of a given property, or a default value if the property or its value is null.
    boolean
    hasValue(T value)
    Checks if this property has a given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • random

      protected static final Random random
  • Constructor Details

    • VariableProperty

      public VariableProperty()
  • Method Details

    • getValue

      public abstract T getValue()
      Returns the value of this property.
      Returns:
      The value of this property.
    • exists

      public boolean exists()
      Checks if this property has any value.
      Returns:
      true if the value of this property is not null.
    • hasValue

      public boolean hasValue(T value)
      Checks if this property has a given value.
      Parameters:
      value - The value to check for
      Returns:
      true if the value of this property is equal to value.
    • getValue

      @Contract("null -> null") public static <T> T getValue(VariableProperty<T> property)
      Returns the value of a given property, or null if the property is null.
      Type Parameters:
      T - The type of value
      Parameters:
      property - The property or null
      Returns:
      The value
    • getValue

      @Contract("null, _ -> param2") public static <T> T getValue(VariableProperty<T> property, T defaultValue)
      Returns the value of a given property, or a default value if the property or its value is null.
      Type Parameters:
      T - The type of value
      Parameters:
      property - The property or null
      defaultValue - The value to use in case the property or its value is null.
      Returns:
      The value