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>
Represents the classification of HTTP status codes based on their first digit. Each enum constant corresponds to one of the standard HTTP status code classes.
Since:
2.0.0
Author:
Erik C. Thauvin
  • Enum Constant Details

    • INFORMATIONAL

      public static final StatusCodeClass INFORMATIONAL
      Status codes starting with 1.
    • SUCCESSFUL

      public static final StatusCodeClass SUCCESSFUL
      Status codes starting with 2.
    • REDIRECTION

      public static final StatusCodeClass REDIRECTION
      Status codes starting with 3.
    • CLIENT_ERROR

      public static final StatusCodeClass CLIENT_ERROR
      Status codes starting with 4.
    • SERVER_ERROR

      public static final StatusCodeClass SERVER_ERROR
      Status codes 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)
      Returns the classification corresponding to the given first digit. The digit must be between 1 and 5.

      Returns an empty Optional if the digit does not correspond to a known HTTP status code class.

    • getFirstDigit

      public int getFirstDigit()
      Returns the first digit representing this HTTP status code class.