Package net.thauvin.erik.httpstatus
Enum Class StatusCodeClass
- All Implemented Interfaces:
Serializable
,Comparable<StatusCodeClass>
,Constable
The
StatusCodeClass
enum represents the classification of HTTP status codes into groups
based on their first digit.
Each enum constant corresponds to a specific class of HTTP statuses:
INFORMATIONAL
: Represents HTTP responses with a status code starting with1
SUCCESSFUL
: Represents HTTP responses with a status code starting with2
REDIRECTION
: Represents HTTP responses with a status code starting with3
CLIENT_ERROR
: Represents HTTP responses with a status code starting with4
SERVER_ERROR
: Represents HTTP responses with a status code starting with5
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresents HTTP responses with a status code starting with4
.Represents HTTP responses with a status code starting with1
.Represents HTTP responses with a status code starting with3
.Represents HTTP responses with a status code starting with5
.Represents HTTP responses with a status code starting with2
. -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<StatusCodeClass>
fromFirstDigit
(int firstDigit) Retrieves theStatusCodeClass
corresponding to the given first digit.int
Retrieves the first digit representing the classification of HTTP status codes.static StatusCodeClass
Returns the enum constant of this class with the specified name.static StatusCodeClass[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INFORMATIONAL
Represents HTTP responses with a status code starting with1
. -
SUCCESSFUL
Represents HTTP responses with a status code starting with2
. -
REDIRECTION
Represents HTTP responses with a status code starting with3
. -
CLIENT_ERROR
Represents HTTP responses with a status code starting with4
. -
SERVER_ERROR
Represents HTTP responses with a status code starting with5
.
-
-
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
-
fromFirstDigit
Retrieves theStatusCodeClass
corresponding to the given first digit.- Parameters:
firstDigit
- The first digit of the HTTP status code as a string.- Returns:
- An
Optional
containing the matchingStatusCodeClass
for the provided digit, or an emptyOptional
if no match is found. - See Also:
-
getFirstDigit
public int getFirstDigit()Retrieves the first digit representing the classification of HTTP status codes.- Returns:
- The first digit of the HTTP status code class.
-