Class State

java.lang.Object
com.adobe.granite.ui.components.State

public class State extends Object
A key-value map of client-side state. A client may set a state such that the server can retrieve it to do something specific about this client based on the state.
  • Constructor Details

  • Method Details

    • get

      @CheckForNull public String get(@Nonnull String name)
      Returns the item value of the given name. Returns null if the item is not found.
      Parameters:
      name - the name of the item
      Returns:
      the item value as a string
    • get

      @Nonnull public String get(@Nonnull String name, @Nonnull String defaultValue)
      Returns the item value of the given name. Returns the given defaultValue if the item is not found.
      Parameters:
      name - the name of the item
      defaultValue - the default value
      Returns:
      the item value as a string or the default value if the item is not found
    • get

      public boolean get(@Nonnull String name, boolean defaultValue)
      Returns the item value of the given name. Returns the given defaultValue if the item is not found, or the value is not a boolean string ("true" or "false").
      Parameters:
      name - the name of the item
      defaultValue - the default value
      Returns:
      the item value as a boolean or the default value if the value is not a boolean string
    • get

      public int get(@Nonnull String name, int defaultValue)
      Returns the item value of the given name. Returns the given defaultValue if the item is not found, or the value is not an integer string.
      Parameters:
      name - the name of the item
      defaultValue - the default value
      Returns:
      the item value as an int or the default value if the value is not an int
    • names

      @Nonnull public Iterator<String> names()
      Returns the available names.
      Returns:
      the available names
    • getItem

      @CheckForNull public State.Item getItem(@Nonnull String name)
      Returns the state item with the given name. Returns null if the item is not found.
      Parameters:
      name - the name of the item
      Returns:
      the state item