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 aStateContainersState.A
Statecan include zero or moreStatePropertys. EachStatePropertywithin aStateis mapped to a value which represents the current value at the time theStatewas taken.For example, a
BlockTypes.RED_BEDcontains three possibleStatePropertys :EnumStateProperties.RED_BED_FACINGBooleanStateProperties.RED_BED_OCCUPIEDEnumStateProperties.RED_BED_PART
If you query a
BlockTypes.RED_BED'sStatePropertyyou have two possible outcomes for eachStateProperty. TheBooleanStateProperties.RED_BED_OCCUPIEDhas the following possible values:truefalse
As 'OCCUPIED' is a
BooleanStateProperty, it can only betrueorfalse. TheEnumStateProperties.RED_BED_PARThas the following possible values:HEADFOOT
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
StateContainermay not always have one or moreStatePropertys. 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 thePredicateused 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 returnedCollectionshould 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 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
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
-
-