Class GuiStyleToken<T>

java.lang.Object
com.render.api.gui.style.GuiStyleToken<T>
Type Parameters:
T - property value type

public final class GuiStyleToken<T> extends Object
Shared, typed design value for modern GUI and managed HUD declarations.

Read and mutate tokens on the client thread. Bound declarations retain the token, rather than a value snapshot. Changing a token invalidates its attached sheets and inline components. Ordinary property inheritance and transitions then apply to the newly resolved value. A token never retains its subscribing views strongly.

  • Method Details

    • of

      public static <T> GuiStyleToken<T> of(String name, GuiStyleProperty<T> definition, T value)
      Creates a token using a property's type, validation, and defensive copying rules.
      Type Parameters:
      T - value type
      Parameters:
      name - diagnostic name; token identity, rather than name, determines sharing
      definition - property defining the value contract
      value - initial value
      Returns:
      new token
    • name

      public String name()
      Returns:
      diagnostic name
    • value

      public T value()
      Returns:
      detached current value
    • revision

      public long revision()
      Returns:
      monotonic value revision
    • set

      public GuiStyleToken<T> set(T next)
      Validates and publishes a value. All live bindings validate before any value changes or notification occurs. Equal values are a no-op. Several token changes before the next host synchronization resolve in one pass. Observer failures are rethrown after every remaining live observer has been notified; the value stays published.
      Parameters:
      next - new value
      Returns:
      this token
    • validateBinding

      public void validateBinding(GuiStyleProperty<T> property)
      Validates a binding without registering an observer. Compatible properties may share a token, for example several spacing properties accepting the same float value.
      Parameters:
      property - target property
    • observe

      public RenderRegistration observe(GuiStyleProperty<T> property, Runnable changed)
      Observes a live property binding. Retain the returned handle while the binding is active; the token holds only a weak reference. Closing it stops notifications and releases that target's validation requirement.
      Parameters:
      property - target property
      changed - callback on a changed value
      Returns:
      binding registration