public final class VId extends U16Id implements Comparable<VId>
Creating instances of VId
is done via the static methods
of the class, or by using the predefined constants
NONE
or PRESENT
.
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 virtual identifiers is presented in an intuitive order.
Modifier and Type | Field and Description |
---|---|
static VId |
NONE
A special value denoting the absence of a virtual ID.
|
static VId |
PRESENT
A special value denoting the presence of a virtual ID, without
defining the specific value.
|
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 |
---|---|
int |
compareTo(VId o)
Implements the Comparable interface, to return virtual IDs in
natural order.
|
static String |
specialName(VId v)
Returns the logical name of the given virtual ID if it is a
special value; null otherwise.
|
String |
toString()
Returns a string representation of this id.
|
static VId |
valueOf(byte[] bytes)
Returns an object that represents the virtual ID defined by the
specified byte array.
|
static VId |
valueOf(int vid)
Returns an object that represents the virtual ID defined by
the specified integer.
|
static VId |
valueOf(String s)
Returns an object that represents the virtual ID defined by the
specified string.
|
static VId |
vid(String s)
Convenience method that returns the virtual ID for the given string.
|
rangeCheck, toByteArray
equals, hashCode, toInt
parseIntStr, parseLongStr
getRefQ, keyFromBytes
public static final VId NONE
public static final VId PRESENT
public int compareTo(VId o)
compareTo
in interface Comparable<VId>
o
- the other IDComparable.compareTo(T)
public String toString()
UnsignedIntBasedId
toString
in class UnsignedIntBasedId
public static VId valueOf(int vid)
vid
- the virtual ID numberIllegalArgumentException
- if the ID number is invalidpublic static VId valueOf(String s)
s
- the virtual ID number as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static VId vid(String s)
valueOf(String)
. By using a
static import of this method, more concise code can be written. For
example, the following two statements are equivalent:
VId v = VId.valueOf("8"); VId v = vid("8");
s
- the virtual ID number as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static VId 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.