Interface StateProperty<T extends Comparable<T>>
- All Superinterfaces:
Nameable
- All Known Subinterfaces:
BooleanStateProperty,EnumStateProperty<E>,IntegerStateProperty
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 :
EnumStateProperties.property_FACING()BooleanStateProperties.property_OCCUPIED()EnumStateProperties.property_BED_PART()
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:
truefalse
As 'OCCUPIED' is a BooleanStateProperty, it can only be true
or false.
The EnumStateProperties.property_BED_PART() has the following possible values:
HEADFOOT
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 Summary
Modifier and TypeMethodDescriptionparseValue(String value) Attempts to parse the provided value as a value dictated possible by this state property orOptional.empty()otherwise.Gets all possible values for a specificStateProperty.Gets thePredicateused to determine valid values for this.Gets the class type of theStateProperty's values.
-
Method Details
-
possibleValues
Collection<T> possibleValues()Gets all possible values for a specificStateProperty. The included values may not be in any particular order. The returnedCollectionshould be considered immutable.- Returns:
- All possible values
-
valueClass
Gets the class type of theStateProperty's values.- Returns:
- The value class
-
predicate
Gets thePredicateused to determine valid values for this.StateProperty. Any "value" that returnstruewhenPredicate.test(Object)is called is valid. ThePredicateis specific to this property.- Returns:
- The predicate
-
parseValue
Attempts to parse the provided value as a value dictated possible by this state property orOptional.empty()otherwise.- Parameters:
value- The value to parse- Returns:
- The actual value
-