public final class BigPortNumber extends U32Id implements Distributable, Comparable<BigPortNumber>
All constructors for this class are private.
Creating instances of BigPortNumber
is done via the static
methods on the class.
Instances of this class are immutable, making them inherently threadsafe.
This class overrides UnsignedLongBasedId.equals(java.lang.Object)
and UnsignedLongBasedId.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.
PortNumber
,
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 |
---|---|
static BigPortNumber |
bpn(long port)
Convenience method that simply delegates to
valueOf(long) . |
static BigPortNumber |
bpn(String s)
Convenience method that simply delegates to
valueOf(String) . |
int |
compareTo(BigPortNumber o)
Implements the Comparable interface, to return port numbers in
natural order.
|
static BigPortNumber |
valueFrom(ByteBuffer buffer)
Reads 4 bytes from the specified byte buffer and creates a big port
number instance from their value.
|
static BigPortNumber |
valueOf(byte[] bytes)
Returns an object that represents the port number
defined by the specified byte array.
|
static BigPortNumber |
valueOf(long port)
Returns an object that represents the big port number
defined by the specified long.
|
static BigPortNumber |
valueOf(String s)
Returns an object that represents the big port number
defined by the specified string.
|
rangeCheck, toByteArray
equals, hashCode, toLong, toString
parseIntStr, parseLongStr
getRefQ, keyFromBytes
public int compareTo(BigPortNumber o)
compareTo
in interface Comparable<BigPortNumber>
o
- the other port numberComparable.compareTo(T)
public static BigPortNumber valueOf(long port)
port
- the port numberIllegalArgumentException
- if the port number is invalidpublic static BigPortNumber bpn(long port)
valueOf(long)
.
By statically importing this method, more concise code can be written.
The following two statements are equivalent:
BigPortNumber p = BigPortNumber.valueOf(5); BigPortNumber p = bpn(5);
port
- the port numberIllegalArgumentException
- if the port number is invalidpublic static BigPortNumber valueOf(String s)
s
- the port number as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static BigPortNumber bpn(String s)
valueOf(String)
.
By statically importing this method, more concise code can be written.
The following two statements are equivalent:
BigPortNumber p = BigPortNumber.valueOf("0xa"); BigPortNumber p = bpn("0xa");
s
- the port number as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static BigPortNumber valueOf(byte[] bytes)
U32Id.LENGTH_IN_BYTES
bytes long.bytes
- the encoded idNullPointerException
- if the byte array is nullIllegalArgumentException
- if the byte array is not 4 bytes longpublic static BigPortNumber valueFrom(ByteBuffer buffer)
buffer
- the buffer from which to read bytesBufferUnderflowException
- the buffer does not have sufficient
number of bytes remainingCopyright © 2016. All Rights Reserved.