Class 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.
    • Method Detail

      • 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
      • 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