Interface BlockProperty<T>

Type Parameters:
T - the type of the values
All Known Implementing Classes:
BlockProperty.Choice, BlockProperty.Flag, BlockProperty.Range

public sealed interface BlockProperty<T> permits BlockProperty.Flag, BlockProperty.Range, BlockProperty.Choice<E>
A property of a block type and the values its states take, in state order.
Since:
0.1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A property taking some constants of an enum, each written as its lowercased name.
    static final record 
    A property that is either true or false.
    static final record 
    A property taking every integer from min to max.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Pattern
    The pattern property names and value names must match.
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    indexOf(T value)
    Returns the position of a value in values(), -1 if it is not accepted.
    Returns the property name, for instance facing.
    nameOf(T value)
    Returns the name a value is written as.
    parse(String name)
    Returns the value written as a name, null if none is.
    Returns the accepted values, at least two, in state order.
  • Field Details

    • NAME

      static final Pattern NAME
      The pattern property names and value names must match.
      Since:
      0.1.0
  • Method Details

    • name

      String name()
      Returns the property name, for instance facing.
      Returns:
      the property name, for instance facing
      Since:
      0.1.0
    • values

      List<T> values()
      Returns the accepted values, at least two, in state order.
      Returns:
      the accepted values, at least two, in state order
      Since:
      0.1.0
    • nameOf

      String nameOf(T value)
      Returns the name a value is written as.
      Parameters:
      value - an accepted value
      Returns:
      the name a value is written as
      Throws:
      IllegalArgumentException - if the value is not accepted
      Since:
      0.1.0
    • parse

      @Nullable T parse(String name)
      Returns the value written as a name, null if none is.
      Parameters:
      name - the written value
      Returns:
      the value written as a name, null if none is
      Since:
      0.1.0
    • indexOf

      default int indexOf(T value)
      Returns the position of a value in values(), -1 if it is not accepted.
      Parameters:
      value - the value
      Returns:
      the position of a value in values(), -1 if it is not accepted
      Since:
      0.1.0