-
Notifications
You must be signed in to change notification settings - Fork 43
3.0. Library utilities
A much faster validator than regular expression.
Checks if the UUID string is valid.
String uuid = // ...
UuidValidator.isValid(uuid);
Some tools for UUIDs.
Chenges the version number of a UUID.
UUID v1 = // ...
UUID v4 = UuidUtil.setVersion(v1, 4);
Checks if the UUID is a NIL UUID.
UUID uuid = // ...
UuidUtil.isNil(uuid);
Checks if the UUID is a UUIDv1.
UUID uuid = // ...
UuidUtil.isTimeBased(uuid);
Checks if the UUID is a UUIDv4.
UUID uuid = // ...
UuidUtil.isRandomBased(uuid);
Extracts the creation instant of a UUID.
UUID uuid = /...
Instant instant = UuidUtil.extractInstant(uuid);
Extracts the node identifier of a UUID.
UUID uuid = /...
long nodeid = UuidUtil.extractNodeIdentifier(uuid);
Some tools for COMBs.
Extracts the creation instant of a Prefix COMB.
UUID comb = /...
Instant instant = CombUtil.extractPrefixInstant(comb);
Extracts the creation instant of a Suffix COMB.
UUID comb = /...
Instant instant = CombUtil.extractSuffixInstant(comb);
A better comparator for UUIDs than UUID#compareTo()
.
Sorts a list of objects as UUIDv1 or as unsigned 128-bit integers.
List<UUID> list = // ...
list.sort(new UuidComparator());
Sorts a list of objects as UUIDv1 or as unsigned 128-bit integers.
List<UUID> list = // ...
list.sort(UuidComparator.getDefaultInstance());
Sorts a list of objects as unsigned 128-bit integers.
List<UUID> list = // ...
list.sort(UuidComparator.getOpaqueInstance());
Compares two objects as UUIDv1 or as unsigned 128-bit integers.
UUID uuid1 = // ...
UUID uuid2 = // ...
int result = UuidComparator.defaultCompare(uuid1, uuid2);
Compares two objects as unsigned 128-bit integers.
UUID uuid1 = // ...
UUID uuid2 = // ...
int result = UuidComparator.opaqueCompare(uuid1, uuid2);
Collects the hostname, MAC address and IP address of the current machine.
The calculated identifier is a truncated SHA-256 hash of the collected data.
Calculates a long ID for the current machine.
// returns 0x7bc3cfd7844f46ad
long id = MachineId.getMachineId();
Calculates a UUID for the current machine.
// returns 7bc3cfd7-844f-46ad-51a9-1aa22d3c427a
UUID uuid = MachineId.getMachineUuid();
Generates an identifying string for the current machine.
// returns "hostname FF-FF-FF-FF-FF-FF 255.255.255.255"
String string = MachineId.getMachineString();