public final class MeterId extends U32Id implements Comparable<MeterId>
All constructors for this class are private.
Creating instances of MeterId
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 meter IDs is presented in an intuitive order.
Modifier and Type | Field and Description |
---|---|
static MeterId |
ALL
Represents all meters for stat requests commands.
|
static MeterId |
CONTROLLER
Meter for controller connection.
|
static MeterId |
MAX
Meters are designated by a number from 1 to MAX (0xffff0000).
|
static MeterId |
SLOWPATH
Meter for slow datapath, if any.
|
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(MeterId o)
Implements the Comparable interface, to return meter IDs in
natural order.
|
static MeterId |
mid(String s)
Convenience method that returns the meter ID defined by the specified
string.
|
String |
toString()
Returns a string representation of this id.
|
static MeterId |
valueOf(byte[] bytes)
Returns an object that represents the meter identifier defined by
the specified byte array.
|
static MeterId |
valueOf(long mid)
Returns an object that represents the meter ID defined by the
specified long.
|
static MeterId |
valueOf(String s)
Returns an object that represents the meter ID defined by the
specified string.
|
rangeCheck, toByteArray
equals, hashCode, toLong
parseIntStr, parseLongStr
getRefQ, keyFromBytes
public static final MeterId MAX
public static final MeterId SLOWPATH
public static final MeterId CONTROLLER
public static final MeterId ALL
public String toString()
UnsignedLongBasedId
toString
in class UnsignedLongBasedId
public int compareTo(MeterId o)
compareTo
in interface Comparable<MeterId>
o
- the other meter IDComparable.compareTo(T)
public static MeterId valueOf(long mid)
mid
- the meter IDIllegalArgumentException
- if the meter ID is not u32public static MeterId valueOf(String s)
s
- the meter ID as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static MeterId mid(String s)
valueOf(String)
.
By using a static import of this method, code may be written more
concisely. For example, the following two statements are equivalent:
MeterId m = MeterId.valueOf("35"); MeterId m = mid("35");
s
- the meter ID as a stringIllegalArgumentException
- if the string is invalidNullPointerException
- if the string is nullpublic static MeterId 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.