java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.state.TokenTable

@Internal public final class TokenTable extends Object
Per-view registry of state tokens. Tokens register during view construction and receive sequential ids; registration is frozen once the view is registered. Registration and freezing are expected on a single thread; the frozen flag is volatile so the guard is visible if the engine freezes from another thread.
  • Constructor Details

    • TokenTable

      public TokenTable()
  • Method Details

    • register

      public int register(@NotNull @NotNull StateToken token)
      Registers a token and assigns its id.
      Parameters:
      token - the token to register
      Returns:
      the assigned sequential id, starting at 0
      Throws:
      IllegalStateException - when the table is already frozen
    • freeze

      public void freeze()
      Freezes this table; further register(StateToken) calls throw.
    • isFrozen

      public boolean isFrozen()
      Returns whether freeze() was called.
      Returns:
      true once frozen
    • size

      public int size()
      Returns the number of registered tokens.
      Returns:
      the token count
    • tokens

      @NotNull public @NotNull List<StateToken> tokens()
      Returns the registered tokens in id order.
      Returns:
      an unmodifiable view of the token list