| Modifier and Type | Field and Description |
|---|---|
static int |
BYTES
Size in bytes.
|
static EUID |
ONE |
static EUID |
TWO |
static EUID |
ZERO |
| Constructor and Description |
|---|
EUID(byte[] bytes)
Constructor for creating an
EUID from an array of bytes. |
EUID(byte[] bytes,
int offset)
Constructor for creating an
EUID from an array of bytes. |
EUID(int value) |
EUID(Int128 value) |
EUID(long value) |
EUID(java.lang.String s)
Construct
EUID from a String value. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareDistances(EUID first,
EUID second)
Compare the distances of
first and second from
this, treating our unsigned 128-bit number system as a
ring with values 0 and 2128-1 adjacent. |
int |
compareTo(EUID euid) |
boolean |
equals(java.lang.Object o) |
long |
getLow()
Retrieve the lower 64-bit word of this
EUID. |
long |
getShard()
Retrieve the shard number of this
EUID. |
int |
hashCode() |
int |
routingDistanceFrom(EUID other)
|
byte[] |
toByteArray() |
byte[] |
toByteArray(byte[] bytes,
int offset) |
java.lang.String |
toHexString() |
java.lang.String |
toString() |
static EUID |
valueOf(java.lang.String string) |
public static final EUID ZERO
public static final EUID ONE
public static final EUID TWO
public static final int BYTES
public EUID(java.lang.String s)
EUID from a String value.
Hex conversion is performed.s - The string to convert to an EUID.java.lang.IllegalArgumentException - If s does not contain a valid
EUID.public EUID(int value)
public EUID(long value)
public EUID(Int128 value)
public EUID(byte[] bytes)
EUID from an array of bytes.
The array is most-significant byte first, and must not be
zero length.
If the array is smaller than BYTES, then it is effectively
padded with leading bytes with the correct sign.
If the array is longer than BYTES, then values at index
BYTES and beyond are ignored.
bytes - The array of bytes to be used.java.lang.IllegalArgumentException - if bytes is 0 bytes in length.toByteArray()public EUID(byte[] bytes,
int offset)
EUID from an array of bytes.
The array is most-significant byte first.bytes - The array of bytes to be used.offset - The offset of the bytes to be used.toByteArray()public static EUID valueOf(java.lang.String string)
public long getShard()
EUID.EUID.public long getLow()
EUID.EUID.public int routingDistanceFrom(EUID other)
EUID and the
specified EUID.
Currently the algorithm is numberOfLeadingZeros(this ^ other).
other - The EUID for which to calculate the routing
distance from.public int compareDistances(EUID first, EUID second)
first and second from
this, treating our unsigned 128-bit number system as a
ring with values 0 and 2128-1 adjacent.
The algorithm for calculating distance between two nodes is:
distance = minunsigned((a - b) mod 2128, (b - a) mod 2128)
first - The first ID to calculate distancesecond - The second ID to calculate the distancepublic byte[] toByteArray()
public byte[] toByteArray(byte[] bytes,
int offset)
public int compareTo(EUID euid)
compareTo in interface java.lang.Comparable<EUID>public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toHexString()
public java.lang.String toString()
toString in class java.lang.Object