Interface SessionKey<T>

  • Type Parameters:
    T - the type

    public interface SessionKey<T>
    A key for an object in the session.

    A key is a combination of type and name. A key must have a type, or name, or both.

    A key stored in the session always has a type parameter. That is, all keys returned by SessionData.getKeys() are guaranteed to have a type parameter. A key with a name only can be used to retrieve an item from the session where the type is not known ahead of time.

    • Method Detail

      • of

        static <T> SessionKey<T> of​(Class<T> type)
        Creates a key of the given type with no name.
        Type Parameters:
        T - the type
        Parameters:
        type - the type
        Returns:
        a session key
      • of

        static SessionKey<?> of​(String name)
        Creates a key of the given name with no type.
        Parameters:
        name - the name
        Returns:
        a session key
      • ofType

        static <T> SessionKey<T> ofType​(String name,
                                        T value)
        Creates a key of the given name, and the type of the given object (as provided by Object.getClass()).
        Type Parameters:
        T - the type
        Parameters:
        name - the name
        value - the object who's runtime type will be used as the type of the key
        Returns:
        a session key
      • ofType

        static <T> SessionKey<T> ofType​(T value)
        Creates a key of type of the given object (as provided by Object.getClass()), and no name.
        Type Parameters:
        T - the type
        Parameters:
        value - the object who's runtime type will be used as the type of the key
        Returns:
        a session key