public class NodeId extends Object implements ItemId, Comparable<NodeId>
Modifier and Type | Field and Description |
---|---|
static int |
UUID_BYTE_LENGTH
Number of bytes in a UUID (16).
|
static int |
UUID_FORMATTED_LENGTH
Chars in a UUID String.
|
Constructor and Description |
---|
NodeId(byte[] bytes)
Creates a node identifier from the given 16 bytes.
|
NodeId(long msb,
long lsb)
Creates a node identifier from the given 128 bits.
|
NodeId(String uuidString)
Creates a node identifier from the given UUID string.
|
NodeId(UUID uuid)
Creates a node identifier from the given UUID.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(NodeId that)
Compares this identifier to the given other one.
|
boolean |
denotesNode()
Returns
true to indicate that this is a node identifier. |
boolean |
equals(Object that)
Compares two UUID for equality.
|
long |
getLeastSignificantBits()
Returns the 64 least significant bits of this identifier.
|
long |
getMostSignificantBits()
Returns the 64 most significant bits of this identifier.
|
byte[] |
getRawBytes()
Returns the 16 bytes of this identifier.
|
int |
hashCode()
Returns a hash code of this identifier.
|
static NodeId |
randomId()
Creates a random node identifier using a secure random number generator.
|
String |
toString()
Returns the UUID string representation of this identifier.
|
static NodeId |
valueOf(String uuid)
Returns a node identifier that is represented by the given UUID string.
|
public static final int UUID_FORMATTED_LENGTH
public static final int UUID_BYTE_LENGTH
public NodeId(long msb, long lsb)
msb
- most significant 64 bitslsb
- least significant 64 bitspublic NodeId(byte[] bytes) throws NullPointerException, ArrayIndexOutOfBoundsException
bytes
- array of 16 bytesNullPointerException
- if the given array is null
ArrayIndexOutOfBoundsException
- if the given array is less than 16 bytes longpublic NodeId(UUID uuid)
uuid
- UUIDpublic NodeId(String uuidString) throws IllegalArgumentException
uuidString
- UUID stringIllegalArgumentException
- if the UUID string is invalidpublic static NodeId valueOf(String uuid) throws IllegalArgumentException
uuid
- the UUID stringIllegalArgumentException
- if the given string is null
or not a valid UUIDpublic static NodeId randomId()
public long getMostSignificantBits()
public long getLeastSignificantBits()
public byte[] getRawBytes()
public boolean denotesNode()
true
to indicate that this is a node identifier.denotesNode
in interface ItemId
true
PropertyId
,
NodeId
public int compareTo(NodeId that)
compareTo
in interface Comparable<NodeId>
that
- other identifierpublic String toString()
toString
in class Object
UUID.toString()
public boolean equals(Object that)
equals
in class Object
Object.equals(Object)
Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.