Interface StateProperty<T extends Comparable<T>>

All Superinterfaces:
All Known Subinterfaces:
BooleanStateProperty, EnumStateProperty<E>, IntegerStateProperty

public interface StateProperty<T extends Comparable<T>> extends Nameable
Represents a possible state property in a StateContainers State.

A State can include zero or more StatePropertys. Each StateProperty within a State is mapped to a value which represents the current value at the time the State was taken.

For example, a BlockTypes.RED_BED contains three possible StatePropertys :

If you query a BlockTypes.RED_BED's StateProperty you have two possible outcomes for each StateProperty. The BooleanStateProperties.property_OCCUPIED() has the following possible values:

  • true
  • false

As 'OCCUPIED' is a BooleanStateProperty, it can only be true or false. The EnumStateProperties.property_BED_PART() has the following possible values:

  • HEAD
  • FOOT

To determine the current value of a StateProperty, you would call State.stateProperty(StateProperty). To determine all possible values of a StateProperty, you would call State.stateProperties().

As stated above, a StateContainer may not always have one or more StatePropertys. An example of such a block is BlockTypes.BOOKSHELF.

  • Method Details

    • possibleValues

      Collection<T> possibleValues()
      Gets all possible values for a specific StateProperty. The included values may not be in any particular order. The returned Collection should be considered immutable.
      All possible values
    • valueClass

      Class<T> valueClass()
      Gets the class type of the StateProperty's values.
      The value class
    • predicate

      Predicate<T> predicate()
      Gets the Predicate used to determine valid values for this. StateProperty. Any "value" that returns true when Predicate.test(Object) is called is valid. The Predicate is specific to this property.
      The predicate
    • parseValue

      Optional<T> parseValue(String value)
      Attempts to parse the provided value as a value dictated possible by this state property or Optional.empty() otherwise.
      value - The value to parse
      The actual value