Class AuthenticationState


  • public class AuthenticationState
    extends Object

    Maintains state information and provides to retrieve values in a type safe manner.

    State values are represented with standard Java objects: String, Number, Boolean, Map, List, Set and null.
    Since:
    2.0.0
    • Constructor Detail

      • AuthenticationState

        public AuthenticationState()
        Creates a new AuthenticationState instance.
    • Method Detail

      • add

        public AuthenticationState add​(String key,
                                       Object object)

        Adds the specified value.

        If adding to a list value, the specified key must be parseable as an unsigned base-10 integer and be less than or equal to the list size. Adding a value to a list shifts any existing elements at or above the specified index to the right by one.

        Parameters:
        key - The Map key or List index to add.
        object - The Java object to add.
        Returns:
        This AuthenticationState.
        Throws:
        AuthenticationStateException - If not a Map or the Map key already exists.
      • isDefined

        public boolean isDefined​(String key)
        Returns true if this AuthenticationState contains the specified item.
        Parameters:
        key - The Map key or List index of the item to seek.
        Returns:
        true if this AuthenticationState contains the specified member.
        Throws:
        NullPointerException - If key is null.
      • get

        public AuthenticationState get​(String key)
        Returns the specified item value. If no such member value exists, then a AuthenticationState containing null is returned.
        Parameters:
        key - The Map key or List index identifying the item to return.
        Returns:
        a AuthenticationState containing the value or null.
      • asBoolean

        public Boolean asBoolean()
        Returns the AuthenticationState as a Boolean object. If the value is null, this method returns null.
        Returns:
        The boolean value.
        Throws:
        AuthenticationStateException - If the value is not a boolean type.
      • asInteger

        public Integer asInteger()
        Returns the AuthenticationState as an Integer object. This may involve rounding or truncation. If the value is null, this method returns null.
        Returns:
        The integer value.
        Throws:
        AuthenticationStateException - If the value is not a number.