public final class BufferId extends U32Id implements Comparable<BufferId>
All constructors for this class are private.
Creating instances of BufferId
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 buffer IDs is presented in an intuitive order.
Modifier and Type | Field and Description |
---|---|
static BufferId |
NO_BUFFER
Denotes no buffer available on the switch.
|
E_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 BufferId |
bid(String s)
Convenience method that invokes
valueOf(String) . |
int |
compareTo(BufferId o)
Implements the Comparable interface, to return buffer IDs in
natural order.
|
String |
toString()
Returns a string representation of this id.
|
static BufferId |
valueOf(byte[] bytes)
Returns an object that represents the buffer identifier
defined by the specified byte array.
|
static BufferId |
valueOf(long bid)
Returns an object that represents the buffer ID defined by the
specified long value.
|
static BufferId |
valueOf(String s)
Returns an object that represents the buffer ID defined by the
specified string.
|
rangeCheck, toByteArray
equals, hashCode, toLong
parseIntStr, parseLongStr
getRefQ, keyFromBytes
public static final BufferId NO_BUFFER
public String toString()
UnsignedLongBasedId
toString
in class UnsignedLongBasedId
public int compareTo(BufferId o)
compareTo
in interface Comparable<BufferId>
o
- the other buffer IDComparable.compareTo(T)
public static BufferId valueOf(long bid)
bid
- the buffer IDIllegalArgumentException
- if the buffer ID is not u32public static BufferId valueOf(String s)
s
- the buffer ID as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static BufferId bid(String s)
valueOf(String)
. This method
can be statically imported to make code more concise. For example, the
following two statements are equivalent:
BufferId b = BufferId.valueOf(23); BufferId b = bid(23);
s
- the buffer ID as a stringpublic static BufferId 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 longCopyright © 2015. All Rights Reserved.