Package org.apache.juneau.http
Record Class HttpProtocolVersion
java.lang.Object
java.lang.Record
org.apache.juneau.http.HttpProtocolVersion
- Record Components:
protocol- The protocol name (e.g."HTTP"). Must not benull .major- The major version number (e.g.1).minor- The minor version number (e.g.1).
The HTTP protocol version that appears in request and response start lines (e.g.
"HTTP/1.1").
Mirrors the semantics of org.apache.http.ProtocolVersion without the Apache HttpCore dependency.
The protocol name and major/minor numbers are stored separately so callers can compare versions numerically.
Create instances via of(String, int, int) or parse(String):
- Since:
- 10.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HttpProtocolVersionHTTP/1.0.static final HttpProtocolVersionHTTP/1.1.static final HttpProtocolVersionHTTP/2.0. -
Constructor Summary
ConstructorsConstructorDescriptionHttpProtocolVersion(String protocol, int major, int minor) Canonical constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intmajor()Returns the value of themajorrecord component.intminor()Returns the value of theminorrecord component.static HttpProtocolVersionCreates a protocol version with the given protocol name and version numbers.static HttpProtocolVersionParses a wire-format protocol version string.protocol()Returns the value of theprotocolrecord component.toString()Returns the canonical wire-format string (e.g.
-
Field Details
-
HTTP_1_0
HTTP/1.0. -
HTTP_1_1
HTTP/1.1. -
HTTP_2_0
HTTP/2.0.
-
-
Constructor Details
-
HttpProtocolVersion
Canonical constructor.- Parameters:
protocol- The protocol name. Must not benull .major- The major version (must be>= 0).minor- The minor version (must be>= 0).
-
-
Method Details
-
of
Creates a protocol version with the given protocol name and version numbers.- Parameters:
protocol- The protocol name (e.g."HTTP"). Must not benull .major- The major version number.minor- The minor version number.- Returns:
- A new instance. Never
null .
-
parse
Parses a wire-format protocol version string.Accepts the standard
PROTOCOL/major.minorform (e.g."HTTP/1.1") and the abbreviatedPROTOCOL/majorform (e.g."HTTP/2", which is parsed as major=2, minor=0).- Parameters:
s- The protocol version string. Must not benull .- Returns:
- A new instance. Never
null . - Throws:
IllegalArgumentException- If the string cannot be parsed.
-
toString
Returns the canonical wire-format string (e.g."HTTP/1.1"). -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
protocol
Returns the value of theprotocolrecord component.- Returns:
- the value of the
protocolrecord component
-
major
Returns the value of themajorrecord component.- Returns:
- the value of the
majorrecord component
-
minor
Returns the value of theminorrecord component.- Returns:
- the value of the
minorrecord component
-