public interface BlockTrait<T extends Comparable<T>> extends CatalogType
BlockType
s BlockState
.
A BlockState
can include zero or more BlockTrait
s. Each
BlockTrait
within a BlockState
is mapped to a value which
represents the current value at the time the BlockState
was taken.
For example, a BlockTypes.BED
contains three possible
BlockTrait
s :
If you query a BlockTypes.BED
's BlockTrait
you have two
possible outcomes for each BlockTrait
. The
BooleanTraits.BED_OCCUPIED
has the following possible values :
true
false
As 'OCCUPIED' is a BooleanTrait
, it can only be true
or false
.
The EnumTraits.BED_PART
has the following possible values :
HEAD
FOOT
To determine the current value of a BlockTrait
, you would call
BlockState.getTraitValue(BlockTrait)
. To determine all possible
values of a BlockTrait
, you would call
BlockType.getTraits()
.
As stated above, a BlockType
may not always have one or more
BlockTrait
s. An example of such a block is
BlockTypes.BOOKSHELF
.
Modifier and Type | Method and Description |
---|---|
String |
getName()
Gets the name of this
BlockTrait . |
Collection<T> |
getPossibleValues()
Gets all possible values for a specific
BlockTrait . |
Predicate<T> |
getPredicate()
Gets the
Predicate used to determine valid values for this. |
Class<T> |
getValueClass()
Gets the class type of the
BlockTrait 's values. |
Optional<T> |
parseValue(String value)
Attempts to parse the provided value as a value dictated possible by this trait or
Optional.empty() otherwise. |
getId
String getName()
BlockTrait
.getName
in interface CatalogType
Collection<T> getPossibleValues()
BlockTrait
. The
included values may not be in any particular order. The returned
Collection
should be considered immutable.Class<T> getValueClass()
BlockTrait
's values.Predicate<T> getPredicate()
Predicate
used to determine valid values for this.
BlockTrait
. Any "value" that returns true
when
Predicate.test(Object)
is called is valid. The
Predicate
is specific to this trait.Optional<T> parseValue(String value)
Optional.empty()
otherwise.value
- The value to parse