public class DDTraceId extends Object
It contains generation of new ids, parsing, and to string for both decimal and hex representations. The decimal string representation is either kept from parsing, or generated on demand and cached.
| Modifier and Type | Field and Description |
|---|---|
static DDTraceId |
MAX |
static DDTraceId |
ONE |
static DDTraceId |
ZERO |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
static DDTraceId |
from(long id)
Create a new
DDTraceId from the given long interpreted as the bits of the
unsigned 64 bit id. |
static DDTraceId |
from(String s)
Create a new
DDTraceId from the given String representation of the unsigned 64
bit id. |
static DDTraceId |
fromHex(String s)
Create a new
DDTraceId from the given String hex representation of the unsigned
64 bit id. |
static DDTraceId |
fromHexTruncatedWithOriginal(String s)
Create a new
DDTraceId from the given String hex representation of the unsigned
64 bit (or more) id truncated to 64 bits, while retaining the original String
representation for use in headers. |
int |
hashCode() |
String |
toHexString()
Returns the no zero padded hex representation, in lower case, of the unsigned 64 bit id.
|
String |
toHexStringOrOriginal()
Returns the no zero padded hex representation, in lower case, of the unsigned 64 bit id, or the
original
String used to create this DDId. |
String |
toHexStringPadded(int size)
Returns the zero padded hex representation, in lower case, of the unsigned 64 bit id.
|
long |
toLong()
Returns the id as a long representing the bits of the unsigned 64 bit id.
|
String |
toString()
Returns the decimal string representation of the unsigned 64 bit id.
|
public static final DDTraceId ZERO
public static final DDTraceId MAX
public static final DDTraceId ONE
public static DDTraceId from(long id)
DDTraceId from the given long interpreted as the bits of the
unsigned 64 bit id. This means that values larger than Long.MAX_VALUE will be represented as
negative numbers.id - long representing the bits of the unsigned 64 bit idpublic static DDTraceId from(String s) throws NumberFormatException
DDTraceId from the given String representation of the unsigned 64
bit id.s - String of unsigned 64 bit idNumberFormatExceptionpublic static DDTraceId fromHex(String s) throws NumberFormatException
DDTraceId from the given String hex representation of the unsigned
64 bit id.s - String in hex of unsigned 64 bit idNumberFormatExceptionpublic static DDTraceId fromHexTruncatedWithOriginal(String s) throws NumberFormatException
DDTraceId from the given String hex representation of the unsigned
64 bit (or more) id truncated to 64 bits, while retaining the original String
representation for use in headers.s - String in hex of unsigned 64 bit (or more) idNumberFormatExceptionpublic String toString()
String will be
cached.public String toHexString()
String will NOT be cached.public String toHexStringPadded(int size)
String will NOT be cached.size - the size in characters of the 0 padded String (rounded up to 16 or 32)public String toHexStringOrOriginal()
String used to create this DDId. The hex String will NOT be
cached.public long toLong()