Class HttpStatusLineBean

java.lang.Object
org.apache.juneau.http.response.HttpStatusLineBean
All Implemented Interfaces:
HttpStatusLine

public final class HttpStatusLineBean extends Object implements HttpStatusLine
Default immutable implementation of HttpStatusLine.

Create instances via the static factory methods:

// 200 OK HTTP/1.1 HttpStatusLine sl = HttpStatusLineBean.of(200, "OK"); // Custom protocol version (parsed) HttpStatusLine sl2 = HttpStatusLineBean.of("HTTP/2", 200, "OK"); // Custom protocol version (typed) HttpStatusLine sl3 = HttpStatusLineBean.of(HttpProtocolVersion.HTTP_2_0, 200, "OK");

See Also:
Since:
9.2.1
  • Method Details

    • of

      public static HttpStatusLineBean of(int statusCode, String reasonPhrase)
      Creates an HTTP/1.1 status line with the given status code and reason phrase.
      Parameters:
      statusCode - The HTTP status code (e.g. 200).
      reasonPhrase - The reason phrase (e.g. "OK"). May be null.
      Returns:
      A new instance. Never null.
    • of

      public static HttpStatusLineBean of(String protocolVersion, int statusCode, String reasonPhrase)
      Creates a status line with a parsed protocol version, status code, and reason phrase.
      Parameters:
      protocolVersion - The protocol version string (e.g. "HTTP/2"). Must not be null.
      statusCode - The HTTP status code.
      reasonPhrase - The reason phrase. May be null.
      Returns:
      A new instance. Never null.
    • of

      public static HttpStatusLineBean of(HttpProtocolVersion protocolVersion, int statusCode, String reasonPhrase)
      Creates a status line with the given typed protocol version, status code, and reason phrase.
      Parameters:
      protocolVersion - The protocol version. Must not be null.
      statusCode - The HTTP status code.
      reasonPhrase - The reason phrase. May be null.
      Returns:
      A new instance. Never null.
    • getStatusCode

      public int getStatusCode()
      Description copied from interface: HttpStatusLine
      Returns the HTTP status code (e.g. 200, 404).
      Specified by:
      getStatusCode in interface HttpStatusLine
      Returns:
      The status code.
    • getReasonPhrase

      Description copied from interface: HttpStatusLine
      Returns the human-readable reason phrase (e.g. "OK", "Not Found"), or null if absent.
      Specified by:
      getReasonPhrase in interface HttpStatusLine
      Returns:
      The reason phrase, possibly null.
    • getProtocolVersion

      Description copied from interface: HttpStatusLine
      Returns the HTTP protocol version (e.g. HttpProtocolVersion.HTTP_1_1).
      Specified by:
      getProtocolVersion in interface HttpStatusLine
      Returns:
      The protocol version. Never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object