Class Structure

java.lang.Object
com.cotani.gui.layout.Structure

public final class Structure extends Object
Parsed matrix layout that maps symbols to inventory slots.

Each row is a whitespace-separated list of single-character tokens, at most 9 tokens per row and 6 rows per structure. The slot of a token at row r and column c is r * 9 + c. The character '.' is reserved for intentionally empty slots and is never recorded.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    Reserved symbol for intentionally empty slots.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Structure
    parse(String... rows)
    Parses row patterns such as "# # #" and "# F #" into a structure.
    int
    Returns the number of rows declared by this structure.
    int
    Returns the total inventory size required by this structure (rows * 9).
    slots(char symbol)
    Returns the slots assigned to the given symbol, in reading order.
    Returns all symbols declared by this structure.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EMPTY

      public static final char EMPTY
      Reserved symbol for intentionally empty slots.
      See Also:
  • Method Details

    • parse

      public static Structure parse(String... rows)
      Parses row patterns such as "# # #" and "# F #" into a structure.
      Parameters:
      rows - the row patterns, between 1 and 6 entries
      Returns:
      the parsed structure
      Throws:
      IllegalArgumentException - when a row has more than 9 tokens, a token is not a single character, or the row count is outside 1..6
    • rows

      public int rows()
      Returns the number of rows declared by this structure.
      Returns:
      the row count, between 1 and 6
    • size

      public int size()
      Returns the total inventory size required by this structure (rows * 9).
      Returns:
      the slot count
    • slots

      public List<Integer> slots(char symbol)
      Returns the slots assigned to the given symbol, in reading order.
      Parameters:
      symbol - the structure symbol
      Returns:
      an immutable list of slots, empty when the symbol is absent
    • symbols

      public Set<Character> symbols()
      Returns all symbols declared by this structure.
      Returns:
      an immutable set of symbols