Package io.microsphere.spring.web.util
Enum WebServerScope
- java.lang.Object
-
- java.lang.Enum<WebServerScope>
-
- io.microsphere.spring.web.util.WebServerScope
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<WebServerScope>
public enum WebServerScope extends java.lang.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
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> TgetAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name)Return the request attribute value if present.static <T> TgetAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name, int scope)Get the attribute value by the specified namejava.lang.String[]getAttributeNames(org.springframework.web.server.ServerWebExchange serverWebExchange)Get all attribute names in the specifiedServerWebExchange.static java.lang.String[]getAttributeNames(org.springframework.web.server.ServerWebExchange serverWebExchange, int scope)Get all attribute names in the specifiedServerWebExchangeby the scope<T> TgetAttributeOrDefault(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name, T defaultValue)Return the request attribute value, or a default, fallback value.protected abstract java.util.Map<java.lang.String,java.lang.Object>getAttributes(org.springframework.web.server.ServerWebExchange serverWebExchange)<T> TgetRequiredAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name)Return the request attribute value or if not present raise anIllegalArgumentException.java.lang.ObjectremoveAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name)Remove the request attribute by the specified name.static java.lang.ObjectremoveAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name, int scope)Remove the attribute by the specified namejava.lang.ObjectsetAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name, java.lang.Object value)Set the request attribute value.static java.lang.ObjectsetAttribute(org.springframework.web.server.ServerWebExchange serverWebExchange, java.lang.String name, java.lang.Object value, int scope)Set the attribute valueintvalue()Get the value of the scopestatic WebServerScopevalueOf(int scope)Resolve theWebServerScopeby the specified scope valuestatic WebServerScopevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static WebServerScope[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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 Detail
-
values
public static WebServerScope[] 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 (WebServerScope c : WebServerScope.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static WebServerScope 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 namejava.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.server.ServerWebExchange serverWebExchange, @Nullable java.lang.String name)Return the request attribute value if present.- Type Parameters:
T- the attribute type- Parameters:
serverWebExchange-ServerWebExchangename- the attribute name- Returns:
- the attribute value
-
setAttribute
public java.lang.Object setAttribute(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, @Nullable java.lang.String name, @Nullable java.lang.Object value)Set the request attribute value.- Parameters:
serverWebExchange-ServerWebExchangename- the attribute namevalue- the attribute value- Returns:
- the previous attribute value if the attribute exists, or
null
-
removeAttribute
public java.lang.Object removeAttribute(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, @Nullable java.lang.String name)Remove the request attribute by the specified name.- Parameters:
serverWebExchange-ServerWebExchangename- 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 java.lang.String name)Return the request attribute value or if not present raise anIllegalArgumentException.- Type Parameters:
T- the attribute type- Parameters:
serverWebExchange-ServerWebExchangename- the attribute name- Returns:
- the attribute value
-
getAttributeOrDefault
@Nullable public <T> T getAttributeOrDefault(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange, @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:
serverWebExchange-ServerWebExchangename- the attribute namedefaultValue- a default value to return instead- Returns:
- the attribute value
-
getAttributeNames
@Nonnull public java.lang.String[] getAttributeNames(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange)Get all attribute names in the specifiedServerWebExchange.- Parameters:
serverWebExchange-ServerWebExchange- Returns:
- an array of attribute names, never
null
-
getAttributes
@Nonnull protected abstract java.util.Map<java.lang.String,java.lang.Object> getAttributes(@Nonnull org.springframework.web.server.ServerWebExchange serverWebExchange)
-
valueOf
@Nonnull public static WebServerScope valueOf(int scope) throws java.lang.IllegalArgumentException
Resolve theWebServerScopeby the specified scope value- Parameters:
scope- the scope value- Returns:
- the
WebServerScope - 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.server.ServerWebExchange serverWebExchange, @Nullable java.lang.String name, int scope) throws java.lang.IllegalArgumentExceptionGet the attribute value by the specified name- Type Parameters:
T- the attribute value type- Parameters:
serverWebExchange-ServerWebExchangesourcename- the attribute namescope- the scope value- Returns:
- the attribute value or
nullif 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.server.ServerWebExchange serverWebExchange, @Nullable java.lang.String name, @Nullable java.lang.Object value, int scope) throws java.lang.IllegalArgumentExceptionSet the attribute value- Parameters:
serverWebExchange-ServerWebExchangesourcename- the attribute namevalue- the attribute valuescope- 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.server.ServerWebExchange serverWebExchange, @Nullable java.lang.String name, int scope) throws java.lang.IllegalArgumentExceptionRemove the attribute by the specified name- Parameters:
serverWebExchange-ServerWebExchangesourcename- the attribute namescope- 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.server.ServerWebExchange serverWebExchange, int scope) throws java.lang.IllegalArgumentExceptionGet all attribute names in the specifiedServerWebExchangeby the scope- Parameters:
serverWebExchange-ServerWebExchangesourcescope- the scope value- Returns:
- an array of attribute names, never
null - Throws:
java.lang.IllegalArgumentException- if the scope value is not recognized
-
-