Enum Class HttpMethod
- All Implemented Interfaces:
Serializable,Comparable<HttpMethod>,Constable
The RequestMethod enum represents the different HTTP request methods, such as POST, GET, PUT, DELETE, PATCH, and HEAD.
It also includes the UNKNOWN value for unrecognized methods.
The enum provides methods to parse and convert these methods to strings and arrays for use in HTTP request handling.
- Since:
- 1.0.0-SNAPSHOT
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresents all request methodsRepresents all request methods + raw request methodsRepresents the CONNECT request methodRepresents the DELETE request methodRepresents the GET request methodRepresents the HEAD request methodRepresents the OPTIONS request methodRepresents the PATCH request methodRepresents the POST request methodRepresents the PUT request methodRepresents the TRACE request methodRepresents an unrecognized request method -
Method Summary
Modifier and TypeMethodDescriptionstatic StringasString(HttpMethod... methods) Deprecated, for removal: This API element is subject to removal in a future version.static String[]convert(HttpMethod... methods) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofnormalize(HttpMethod...).Get the array of strings containing the request methods for this enum value.booleanCheck if the HTTP method allows a request body.booleanCheck if the HTTP method allows a response body.static Stringjoin(@NotNull CharSequence delimiter, HttpMethod @NotNull ... methods) Joins the names of the providedHttpMethodvalues into a single string using the specified delimiter.static Stringjoin(HttpMethod @NotNull ... methods) Joins the names of the providedHttpMethodvalues using the default delimiter "|".static HttpMethod[]normalize(HttpMethod @NotNull ... methods) Normalizes the provided array of HttpMethod values by: Removing null values Excluding UNKNOWN methods Flattening ALL and ALL_RAW into their actual method components Removing duplicatesstatic HttpMethodParse the given HTTP request method string and return the corresponding RequestMethod enum value.toString()Get the string representation of the enum value.static HttpMethodReturns the enum constant of this class with the specified name.static HttpMethod[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
CONNECT
Represents the CONNECT request method -
POST
Represents the POST request method -
GET
Represents the GET request method -
PUT
Represents the PUT request method -
DELETE
Represents the DELETE request method -
PATCH
Represents the PATCH request method -
HEAD
Represents the HEAD request method -
OPTIONS
Represents the OPTIONS request method -
TRACE
Represents the TRACE request method -
UNKNOWN
Represents an unrecognized request method -
ALL
Represents all request methods -
ALL_RAW
Represents all request methods + raw request methods
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getMethods
Get the array of strings containing the request methods for this enum value.- Returns:
- The array of request methods as strings.
-
isRequestBodyAble
public boolean isRequestBodyAble()Check if the HTTP method allows a request body.- Returns:
- true if the HTTP method allows a request body, otherwise false.
-
isResponseBodyAble
public boolean isResponseBodyAble()Check if the HTTP method allows a response body.- Returns:
- true if the HTTP method allows a response body, otherwise false.
-
toString
Get the string representation of the enum value. For the ALL value, it returns the concatenated string of all methods. For other values, it returns the default string representation of the enum value.- Overrides:
toStringin classEnum<HttpMethod>- Returns:
- The string representation of the enum value.
-
parse
Parse the given HTTP request method string and return the corresponding RequestMethod enum value. If the method string is not recognized, it returns the UNKNOWN value.- Parameters:
method- The HTTP request method as a string.- Returns:
- The corresponding RequestMethod enum value or UNKNOWN if not recognized.
-
normalize
Normalizes the provided array of HttpMethod values by:- Removing null values
- Excluding UNKNOWN methods
- Flattening ALL and ALL_RAW into their actual method components
- Removing duplicates
- Parameters:
methods- The array of HttpMethod values to normalize- Returns:
- A normalized array of distinct, valid HttpMethod values
- Since:
- 3.4.3-SNAPSHOT
-
join
Joins the names of the providedHttpMethodvalues using the default delimiter "|". The methods are normalized before joining.- Parameters:
methods- The array of HttpMethod values to join.- Returns:
- A single string of method names separated by the default delimiter.
- Since:
- 3.4.3-SNAPSHOT
-
join
public static String join(@NotNull @NotNull CharSequence delimiter, HttpMethod @NotNull ... methods) Joins the names of the providedHttpMethodvalues into a single string using the specified delimiter. The methods are normalized before joining.- Parameters:
delimiter- The string used to separate method names.methods- The array of HttpMethod values to join.- Returns:
- A string of joined method names, or an empty string if methods is null or empty.
- Since:
- 3.4.3-SNAPSHOT
-
convert
@Deprecated(since="3.4.3-SNAPSHOT", forRemoval=true) public static String[] convert(HttpMethod... methods) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofnormalize(HttpMethod...).Convert an array of RequestMethod enum values to an array of strings representing the request methods. If the array contains the ALL value, it returns all methods as an array. It filters out UNKNOWN and ALL values from the array during conversion.- Parameters:
methods- The array of RequestMethod enum values.- Returns:
- The array of strings representing the request methods.
-
asString
@Deprecated(since="3.4.3-SNAPSHOT", forRemoval=true) public static String asString(HttpMethod... methods) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofjoin(HttpMethod...).Convert an array of RequestMethod enum values to a single string representation of request methods. The string contains the request methods separated by the "|" character.- Parameters:
methods- The array of RequestMethod enum values.- Returns:
- The string representation of request methods separated by "|".
-
join(HttpMethod...).