Interface StateProperty<T extends java.lang.Comparable<T>>
-
- All Superinterfaces:
Nameable
- All Known Subinterfaces:
BooleanStateProperty
,EnumStateProperty<E>
,IntegerStateProperty
public interface StateProperty<T extends java.lang.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 java.util.Optional<T>
parseValue(java.lang.String value)
Attempts to parse the provided value as a value dictated possible by this state property orOptional.empty()
otherwise.java.util.Collection<T>
possibleValues()
Gets all possible values for a specificStateProperty
.java.util.function.Predicate<T>
predicate()
Gets thePredicate
used to determine valid values for this.java.lang.Class<T>
valueClass()
Gets the class type of theStateProperty
's values.
-
-
-
Method Detail
-
possibleValues
java.util.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
java.lang.Class<T> valueClass()
Gets the class type of theStateProperty
's values.- Returns:
- The value class
-
predicate
java.util.function.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
java.util.Optional<T> parseValue(java.lang.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
-
-