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

@Internal public final class StateStore extends Object
Per-session state storage: an array indexed by token id plus the set of dirty token ids awaiting the next coalesced flush. Owned by the session and dropped with it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StateStore(int size)
    Creates storage sized for a view's token table.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Set<Integer>
    Returns the dirty token ids and clears the dirty set.
    @Nullable Object
    get(int id)
    Returns the stored value for a token id.
    boolean
    Returns whether any token id is currently marked dirty.
    void
    markDirty(int id)
    Marks a token id dirty for the next flush; duplicate marks coalesce.
    void
    set(int id, @Nullable Object value)
    Stores a value for a token id, replacing any previous value.

    Methods inherited from class java.lang.Object

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

    • StateStore

      public StateStore(int size)
      Creates storage sized for a view's token table.
      Parameters:
      size - the token count of the owning view
  • Method Details

    • get

      @Nullable public @Nullable Object get(int id)
      Returns the stored value for a token id.
      Parameters:
      id - the token id
      Returns:
      the stored value, or null when nothing was stored
    • set

      public void set(int id, @Nullable @Nullable Object value)
      Stores a value for a token id, replacing any previous value.
      Parameters:
      id - the token id
      value - the value to store, possibly null
    • markDirty

      public void markDirty(int id)
      Marks a token id dirty for the next flush; duplicate marks coalesce.
      Parameters:
      id - the token id
    • drainDirty

      @NotNull public @NotNull Set<Integer> drainDirty()
      Returns the dirty token ids and clears the dirty set.
      Returns:
      the ids marked dirty since the last drain
    • hasDirty

      public boolean hasDirty()
      Returns whether any token id is currently marked dirty.
      Returns:
      true when a flush is pending