Enum Class StatusCodeClass

java.lang.Object
java.lang.Enum<StatusCodeClass>
net.thauvin.erik.httpstatus.StatusCodeClass
All Implemented Interfaces:
Serializable, Comparable<StatusCodeClass>, Constable

public enum StatusCodeClass extends Enum<StatusCodeClass>
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 with 1
  • SUCCESSFUL: Represents HTTP responses with a status code starting with 2
  • REDIRECTION: Represents HTTP responses with a status code starting with 3
  • CLIENT_ERROR: Represents HTTP responses with a status code starting with 4
  • SERVER_ERROR: Represents HTTP responses with a status code starting with 5
Since:
2.0.0
  • Enum Constant Details

    • INFORMATIONAL

      public static final StatusCodeClass INFORMATIONAL
      Represents HTTP responses with a status code starting with 1.
    • SUCCESSFUL

      public static final StatusCodeClass SUCCESSFUL
      Represents HTTP responses with a status code starting with 2.
    • REDIRECTION

      public static final StatusCodeClass REDIRECTION
      Represents HTTP responses with a status code starting with 3.
    • CLIENT_ERROR

      public static final StatusCodeClass CLIENT_ERROR
      Represents HTTP responses with a status code starting with 4.
    • SERVER_ERROR

      public static final StatusCodeClass SERVER_ERROR
      Represents HTTP responses with a status code starting with 5.
  • Method Details

    • values

      public static StatusCodeClass[] 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 StatusCodeClass 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
    • fromFirstDigit

      public static Optional<StatusCodeClass> fromFirstDigit(int firstDigit)
      Retrieves the StatusCodeClass corresponding to the given first digit.
      Parameters:
      firstDigit - The first digit of the HTTP status code as a string.
      Returns:
      An Optional containing the matching StatusCodeClass for the provided digit, or an empty Optional 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.