@Contract(threading=IMMUTABLE) public class ProtocolVersion extends Object implements Serializable, Cloneable
This class defines a protocol version as a combination of
protocol name, major version number, and minor version number.
Note that equals(java.lang.Object)
and hashCode()
are defined as
final here, they cannot be overridden in derived classes.
Modifier and Type | Field and Description |
---|---|
protected int |
major
Major version number of the protocol
|
protected int |
minor
Minor version number of the protocol
|
protected String |
protocol
Name of the protocol.
|
Constructor and Description |
---|
ProtocolVersion(String protocol,
int major,
int minor)
Create a protocol version designator.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
int |
compareToVersion(ProtocolVersion that)
Compares this protocol version with another one.
|
boolean |
equals(Object obj)
Checks equality of this protocol version with an object.
|
ProtocolVersion |
forVersion(int major,
int minor)
Obtains a specific version of this protocol.
|
int |
getMajor()
Returns the major version number of the protocol.
|
int |
getMinor()
Returns the minor version number of the HTTP protocol.
|
String |
getProtocol()
Returns the name of the protocol.
|
boolean |
greaterEquals(ProtocolVersion version)
Tests if this protocol version is greater or equal to the given one.
|
int |
hashCode()
Obtains a hash code consistent with
equals(java.lang.Object) . |
boolean |
isComparable(ProtocolVersion that)
Checks whether this protocol can be compared to another one.
|
boolean |
lessEquals(ProtocolVersion version)
Tests if this protocol version is less or equal to the given one.
|
String |
toString()
Converts this protocol version to a string.
|
protected final String protocol
protected final int major
protected final int minor
public ProtocolVersion(String protocol, int major, int minor)
protocol
- the name of the protocol, for example "HTTP"major
- the major version number of the protocolminor
- the minor version number of the protocolpublic final String getProtocol()
public final int getMajor()
public final int getMinor()
public ProtocolVersion forVersion(int major, int minor)
The default implementation in this class returns this
if the version matches, and creates a new ProtocolVersion
otherwise.
major
- the major versionminor
- the minor versionpublic final int hashCode()
equals(java.lang.Object)
.public final boolean equals(Object obj)
public boolean isComparable(ProtocolVersion that)
compared
.that
- the protocol version to considertrue
if compareToVersion
can be called with the argument, false
otherwisepublic int compareToVersion(ProtocolVersion that)
Comparable
.that
- the protocol version to compare withIllegalArgumentException
- if the argument has a different protocol name than this object,
or if the argument is null
public final boolean greaterEquals(ProtocolVersion version)
version
- the version against which to check this versiontrue
if this protocol version is
comparable
to the argument
and compares
as greater or equal,
false
otherwisepublic final boolean lessEquals(ProtocolVersion version)
version
- the version against which to check this versiontrue
if this protocol version is
comparable
to the argument
and compares
as less or equal,
false
otherwisepublic String toString()
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.