public final class PortNumber extends U16Id implements Comparable<PortNumber>
All constructors for this class are private.
Creating instances of PortNumber
is done via the static
methods on the class.
Instances of this class are immutable, making them inherently threadsafe.
This class overrides UnsignedIntBasedId.equals(java.lang.Object)
and UnsignedIntBasedId.hashCode()
so that
instances play nicely with the Collection classes.
This class implements the Comparable
interface to ensure that
a sorted list of port numbers is presented in an intuitive order.
BigPortNumber
,
Serialized FormE_BYTES_BAD_LEN, LENGTH_IN_BYTES, MAX_VALUE
id
E_BAD, E_NULL_BYTES, E_NULL_STR, E_OOR, MIN_VALUE
Modifier and Type | Method and Description |
---|---|
int |
compareTo(PortNumber o)
Implements the Comparable interface, to return port numbers in
natural order.
|
static PortNumber |
valueOf(byte[] bytes)
Returns an object that represents the port number
defined by the specified byte array.
|
static PortNumber |
valueOf(int port)
Returns an object that represents the port number
defined by the specified integer.
|
static PortNumber |
valueOf(String portStr)
Returns an object that represents the port number
defined by the specified string.
|
rangeCheck, toByteArray
equals, hashCode, toInt, toString
parseIntStr, parseLongStr
getRefQ, keyFromBytes
public int compareTo(PortNumber o)
compareTo
in interface Comparable<PortNumber>
o
- the other port numberComparable.compareTo(T)
public static PortNumber valueOf(int port)
port
- the port numberIllegalArgumentException
- if the port number is invalidpublic static PortNumber valueOf(String portStr)
portStr
- the port number as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static PortNumber valueOf(byte[] bytes)
U16Id.LENGTH_IN_BYTES
bytes long.bytes
- the encoded idNullPointerException
- if the byte array is nullIllegalArgumentException
- if the byte array is not 2 bytes longCopyright © 2015. All Rights Reserved.