Class GuidLike
java.lang.Object
io.clonecloudstore.common.standard.guid.GuidLike
UUID Generator with 2 longs (128 bits), compatible multi instances (through the PID,
but not multi servers, neither multi-sites due to lack of Mac address/Platform Id).
Inspired from com.groupon locality-uuid which used combination of internal counter value, process id and Timestamp. see https://github.com/groupon/locality-uuid.java
Benchmark shows about 20 millions/s generated GuidLike, 8 M/s getId().
Inspired from com.groupon locality-uuid which used combination of internal counter value, process id and Timestamp. see https://github.com/groupon/locality-uuid.java
Benchmark shows about 20 millions/s generated GuidLike, 8 M/s getId().
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGuidLike()
Constructor that generates a new UUID using the current process id and MAC address, timestamp and a counterGuidLike
(byte[] bytes) Constructor that takes a byte array as UUID's contentGuidLike
(long valueLow, long valueHigh) Constructor that takes a String representation of a UUID in Base 16 -
Method Summary
-
Field Details
-
UUID_B32_SIZE
public static final int UUID_B32_SIZEGUID Like Base 32 size- See Also:
-
-
Constructor Details
-
GuidLike
public GuidLike()Constructor that generates a new UUID using the current process id and MAC address, timestamp and a counter -
GuidLike
public GuidLike(long valueLow, long valueHigh) -
GuidLike
public GuidLike(byte[] bytes) Constructor that takes a byte array as UUID's content- Parameters:
bytes
- UUID content
-
GuidLike
Constructor that takes a String representation of a UUID in Base 16- Parameters:
idsource
- UUID content as String
-
-
Method Details
-
getGuid
- Returns:
- Convenient method to get String GUID (similar to new GuidLike().getId())
-
getTime
public long getTime()- Returns:
- (pseudo) time
-
getKeySize
public static short getKeySize()- Returns:
- the LongUuid size in bytes
-
getBytes
public byte[] getBytes()copy the uuid of this UUID, so that it can't be changed, and return it- Returns:
- raw byte array of UUID
-
hashCode
public int hashCode() -
equals
-
toString
-
getId
- Returns:
- the Base 32 representation
-
toHex
-
toBase64
-
toBase32
-
getLongLow
public long getLongLow()- Returns:
- the equivalent Low UUID as long
-
getLongHigh
public long getLongHigh()- Returns:
- the equivalent High UUID as long
-