Class GuidLike

java.lang.Object
io.clonecloudstore.common.standard.guid.GuidLike

public final class GuidLike extends Object
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().
  • Field Details

    • UUID_B32_SIZE

      public static final int UUID_B32_SIZE
      GUID 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

      public GuidLike(String idsource)
      Constructor that takes a String representation of a UUID in Base 16
      Parameters:
      idsource - UUID content as String
  • Method Details

    • getGuid

      public static String 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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the Base 32 representation
    • getId

      public String getId()
      Returns:
      the Base 32 representation
    • toHex

      public String toHex()
    • toBase64

      public String toBase64()
    • toBase32

      public String toBase32()
    • getLongLow

      public long getLongLow()
      Returns:
      the equivalent Low UUID as long
    • getLongHigh

      public long getLongHigh()
      Returns:
      the equivalent High UUID as long