Interface StateProperty<T extends Comparable<T>>
- All Superinterfaces:
Nameable
- All Known Subinterfaces:
BooleanStateProperty
,EnumStateProperty<E>
,IntegerStateProperty
StateContainer
s State
.
A State
can include zero or more StateProperty
s. 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
StateProperty
s :
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:
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
StateProperty
s. 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 thePredicate
used 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 returnedCollection
should be considered immutable.- Returns:
- All possible values
-
valueClass
Gets the class type of theStateProperty
's values.- Returns:
- The value class
-
predicate
Gets thePredicate
used to determine valid values for this.StateProperty
. Any "value" that returnstrue
whenPredicate.test(Object)
is called is valid. ThePredicate
is 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
-