Enum Class WebServerScope

java.lang.Object
java.lang.Enum<WebServerScope>
io.microsphere.spring.web.util.WebServerScope
All Implemented Interfaces:
Serializable, Comparable<WebServerScope>, Constable

public enum WebServerScope extends Enum<WebServerScope>
The enumeration of Web Server scopes for Spring Web
Since:
1.0.0
Author:
Mercy
See Also:
  • RequestAttributes.SCOPE_REQUEST
  • RequestAttributes.SCOPE_SESSION
  • Enum Constant Details

    • REQUEST

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

      public static final WebServerScope SESSION
      Session Scope
      See Also:
      • RequestAttributes.SCOPE_SESSION
  • Method Details

    • values

      public static WebServerScope[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static WebServerScope valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      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.server.ServerWebExchange serverWebExchange, @Nullable String name)
      Return the request attribute value if present.
      Type Parameters:
      T - the attribute type
      Parameters:
      serverWebExchange - ServerWebExchange
      name - the attribute name
      Returns:
      the attribute value
    • setAttribute

      public Object setAttribute(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, @Nullable String name, @Nullable Object value)
      Set the request attribute value.
      Parameters:
      serverWebExchange - ServerWebExchange
      name - the attribute name
      value - the attribute value
      Returns:
      the previous attribute value if the attribute exists, or null
    • removeAttribute

      public Object removeAttribute(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, @Nullable String name)
      Remove the request attribute by the specified name.
      Parameters:
      serverWebExchange - ServerWebExchange
      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.server.ServerWebExchange serverWebExchange, @Nullable String name)
      Return the request attribute value or if not present raise an IllegalArgumentException.
      Type Parameters:
      T - the attribute type
      Parameters:
      serverWebExchange - ServerWebExchange
      name - the attribute name
      Returns:
      the attribute value
    • getAttributeOrDefault

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

      @Nonnull public String[] getAttributeNames(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange)
      Get all attribute names in the specified ServerWebExchange.
      Parameters:
      serverWebExchange - ServerWebExchange
      Returns:
      an array of attribute names, never null
    • getAttributes

      @Nonnull protected abstract Map<String,Object> getAttributes(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange)
    • valueOf

      @Nonnull public static WebServerScope valueOf(int scope) throws IllegalArgumentException
      Resolve the WebServerScope by the specified scope value
      Parameters:
      scope - the scope value
      Returns:
      the WebServerScope
      Throws:
      IllegalArgumentException - if the scope value is not recognized
      See Also:
    • getAttribute

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

      @Nullable public static Object setAttribute(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, @Nullable String name, @Nullable Object value, int scope) throws IllegalArgumentException
      Set the attribute value
      Parameters:
      serverWebExchange - ServerWebExchange 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:
      IllegalArgumentException - if the scope value is not recognized
    • removeAttribute

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

      public static String[] getAttributeNames(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, int scope) throws IllegalArgumentException
      Get all attribute names in the specified ServerWebExchange by the scope
      Parameters:
      serverWebExchange - ServerWebExchange source
      scope - the scope value
      Returns:
      an array of attribute names, never null
      Throws:
      IllegalArgumentException - if the scope value is not recognized