Interface StateProperty<T extends Comparable<T>>
-
- All Superinterfaces:
Nameable
- All Known Subinterfaces:
BooleanStateProperty
,EnumStateProperty<E>
,IntegerStateProperty
public interface StateProperty<T extends Comparable<T>> extends Nameable
Represents a possible state property in aStateContainer
sState
.A
State
can include zero or moreStateProperty
s. EachStateProperty
within aState
is mapped to a value which represents the current value at the time theState
was taken.For example, a
BlockTypes.RED_BED
contains three possibleStateProperty
s :EnumStateProperties.RED_BED_FACING
BooleanStateProperties.RED_BED_OCCUPIED
EnumStateProperties.RED_BED_PART
If you query a
BlockTypes.RED_BED
'sStateProperty
you have two possible outcomes for eachStateProperty
. TheBooleanStateProperties.RED_BED_OCCUPIED
has the following possible values:true
false
As 'OCCUPIED' is a
BooleanStateProperty
, it can only betrue
orfalse
. TheEnumStateProperties.RED_BED_PART
has the following possible values:HEAD
FOOT
To determine the current value of a
StateProperty
, you would callState.stateProperty(StateProperty)
. To determine all possible values of aStateProperty
, you would callState.stateProperties()
.As stated above, a
StateContainer
may not always have one or moreStateProperty
s. An example of such a block isBlockTypes.BOOKSHELF
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<T>
parseValue(String value)
Attempts to parse the provided value as a value dictated possible by this state property orOptional.empty()
otherwise.Collection<T>
possibleValues()
Gets all possible values for a specificStateProperty
.Predicate<T>
predicate()
Gets thePredicate
used to determine valid values for this.Class<T>
valueClass()
Gets the class type of theStateProperty
's values.
-
-
-
Method Detail
-
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
Class<T> valueClass()
Gets the class type of theStateProperty
's values.- Returns:
- The value class
-
predicate
Predicate<T> 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
Optional<T> parseValue(String value)
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
-
-