Enum WebScope

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<WebScope>

    public enum WebScope
    extends java.lang.Enum<WebScope>
    The enumeration of scopes for Spring Web
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    RequestAttributes.SCOPE_REQUEST, RequestAttributes.SCOPE_SESSION
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      REQUEST
      Request Scope
      SESSION
      Session Scope
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearAttributes​(org.springframework.web.context.request.RequestAttributes requestAttributes)
      Clear all attributes in the specified RequestAttributes.
      static void clearAttributes​(org.springframework.web.context.request.RequestAttributes requestAttributes, int scope)
      Clear all attributes in the specified RequestAttributes by the scope
      <T> T getAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name)
      Return the request attribute value if present.
      static <T> T getAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name, int scope)
      Get the attribute value by the specified name
      java.lang.String[] getAttributeNames​(org.springframework.web.context.request.RequestAttributes requestAttributes)
      Get all attribute names in the specified RequestAttributes.
      static java.lang.String[] getAttributeNames​(org.springframework.web.context.request.RequestAttributes requestAttributes, int scope)
      Get all attribute names in the specified RequestAttributes by the scope
      <T> T getAttributeOrDefault​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name, T defaultValue)
      Return the request attribute value, or a default, fallback value.
      java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(org.springframework.web.context.request.RequestAttributes requestAttributes)  
      <T> T getRequiredAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name)
      Return the request attribute value or if not present raise an IllegalArgumentException.
      java.lang.Object removeAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name)
      Remove the request attribute by the specified name.
      static java.lang.Object removeAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name, int scope)
      Remove the attribute by the specified name
      java.lang.Object setAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name, java.lang.Object value)
      Set the request attribute value.
      static java.lang.Object setAttribute​(org.springframework.web.context.request.RequestAttributes requestAttributes, java.lang.String name, java.lang.Object value, int scope)
      Set the attribute value
      int value()
      Get the value of the scope
      static WebScope valueOf​(int scope)
      Resolve the WebScope by the specified scope value
      static WebScope valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static WebScope[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • REQUEST

        public static final WebScope REQUEST
        Request Scope
        See Also:
        RequestAttributes.SCOPE_REQUEST
      • SESSION

        public static final WebScope SESSION
        Session Scope
        See Also:
        RequestAttributes.SCOPE_SESSION
    • Method Detail

      • values

        public static WebScope[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (WebScope c : WebScope.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static WebScope valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • value

        public int value()
        Get the value of the scope
        Returns:
        the value of the scope
      • getAttribute

        @Nullable
        public <T> T getAttribute​(@Nonnull
                                  org.springframework.web.context.request.RequestAttributes requestAttributes,
                                  @Nullable
                                  java.lang.String name)
        Return the request attribute value if present.
        Type Parameters:
        T - the attribute type
        Parameters:
        requestAttributes - RequestAttributes
        name - the attribute name
        Returns:
        the attribute value
      • setAttribute

        public java.lang.Object setAttribute​(@Nonnull
                                             org.springframework.web.context.request.RequestAttributes requestAttributes,
                                             @Nullable
                                             java.lang.String name,
                                             @Nullable
                                             java.lang.Object value)
        Set the request attribute value.
        Parameters:
        requestAttributes - RequestAttributes
        name - the attribute name
        value - the attribute value
        Returns:
        the previous attribute value if the attribute exists, or null
      • removeAttribute

        public java.lang.Object removeAttribute​(@Nonnull
                                                org.springframework.web.context.request.RequestAttributes requestAttributes,
                                                @Nullable
                                                java.lang.String name)
        Remove the request attribute by the specified name.
        Parameters:
        requestAttributes - RequestAttributes
        name - the attribute name
        Returns:
        the removed attribute value if the attribute exists, or null
      • getRequiredAttribute

        @Nonnull
        public <T> T getRequiredAttribute​(@Nonnull
                                          org.springframework.web.context.request.RequestAttributes requestAttributes,
                                          @Nullable
                                          java.lang.String name)
        Return the request attribute value or if not present raise an IllegalArgumentException.
        Type Parameters:
        T - the attribute type
        Parameters:
        requestAttributes - RequestAttributes
        name - the attribute name
        Returns:
        the attribute value
      • getAttributeOrDefault

        @Nullable
        public <T> T getAttributeOrDefault​(@Nonnull
                                           org.springframework.web.context.request.RequestAttributes requestAttributes,
                                           @Nullable
                                           java.lang.String name,
                                           @Nullable
                                           T defaultValue)
        Return the request attribute value, or a default, fallback value.
        Type Parameters:
        T - the attribute type
        Parameters:
        requestAttributes - RequestAttributes
        name - the attribute name
        defaultValue - a default value to return instead
        Returns:
        the attribute value
      • getAttributeNames

        @Nonnull
        public java.lang.String[] getAttributeNames​(@Nonnull
                                                    org.springframework.web.context.request.RequestAttributes requestAttributes)
        Get all attribute names in the specified RequestAttributes.
        Parameters:
        requestAttributes - RequestAttributes
        Returns:
        an array of attribute names, never null
      • getAttributes

        @Nonnull
        public java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(@Nonnull
                                                                                    org.springframework.web.context.request.RequestAttributes requestAttributes)
      • clearAttributes

        public void clearAttributes​(@Nonnull
                                    org.springframework.web.context.request.RequestAttributes requestAttributes)
        Clear all attributes in the specified RequestAttributes.
        Parameters:
        requestAttributes - RequestAttributes
      • valueOf

        @Nonnull
        public static WebScope valueOf​(int scope)
                                throws java.lang.IllegalArgumentException
        Resolve the WebScope by the specified scope value
        Parameters:
        scope - the scope value
        Returns:
        the WebScope
        Throws:
        java.lang.IllegalArgumentException - if the scope value is not recognized
        See Also:
        value(), REQUEST, SESSION
      • getAttribute

        @Nullable
        public static <T> T getAttribute​(@Nonnull
                                         org.springframework.web.context.request.RequestAttributes requestAttributes,
                                         @Nullable
                                         java.lang.String name,
                                         int scope)
                                  throws java.lang.IllegalArgumentException
        Get the attribute value by the specified name
        Type Parameters:
        T - the attribute value type
        Parameters:
        requestAttributes - RequestAttributes source
        name - the attribute name
        scope - the scope value
        Returns:
        the attribute value or null if not found
        Throws:
        java.lang.IllegalArgumentException - if the scope value is not recognized
      • setAttribute

        @Nullable
        public static java.lang.Object setAttribute​(@Nonnull
                                                    org.springframework.web.context.request.RequestAttributes requestAttributes,
                                                    @Nullable
                                                    java.lang.String name,
                                                    @Nullable
                                                    java.lang.Object value,
                                                    int scope)
                                             throws java.lang.IllegalArgumentException
        Set the attribute value
        Parameters:
        requestAttributes - RequestAttributes source
        name - the attribute name
        value - the attribute value
        scope - the scope value
        Returns:
        the previous attribute value if the attribute exists, or null
        Throws:
        java.lang.IllegalArgumentException - if the scope value is not recognized
      • removeAttribute

        @Nullable
        public static java.lang.Object removeAttribute​(@Nonnull
                                                       org.springframework.web.context.request.RequestAttributes requestAttributes,
                                                       @Nullable
                                                       java.lang.String name,
                                                       int scope)
                                                throws java.lang.IllegalArgumentException
        Remove the attribute by the specified name
        Parameters:
        requestAttributes - RequestAttributes source
        name - the attribute name
        scope - the scope value
        Returns:
        the removed attribute value if the attribute exists, or null
        Throws:
        java.lang.IllegalArgumentException - if the scope value is not recognized
      • getAttributeNames

        public static java.lang.String[] getAttributeNames​(@Nonnull
                                                           org.springframework.web.context.request.RequestAttributes requestAttributes,
                                                           int scope)
                                                    throws java.lang.IllegalArgumentException
        Get all attribute names in the specified RequestAttributes by the scope
        Parameters:
        requestAttributes - RequestAttributes source
        scope - the scope value
        Returns:
        an array of attribute names, never null
        Throws:
        java.lang.IllegalArgumentException - if the scope value is not recognized
      • clearAttributes

        public static void clearAttributes​(@Nonnull
                                           org.springframework.web.context.request.RequestAttributes requestAttributes,
                                           int scope)
                                    throws java.lang.IllegalArgumentException
        Clear all attributes in the specified RequestAttributes by the scope
        Parameters:
        requestAttributes - RequestAttributes source
        scope - the scope value
        Throws:
        java.lang.IllegalArgumentException - if the scope value is not recognized