Class Guid

  • All Implemented Interfaces:
    Serializable

    public final class Guid
    extends Object
    implements Serializable
    This class represents an universally unique identifier (UUID), also known as globally unique identifier (GUID), see UUID. A UUID represents a 128-bit value and is either guaranteed to be different from all other UUIDs/GUIDs generated until 3400 A.D., or extremely likely to be different.
    This class uses randomly generated UUID, i.e., an UUID of version type 4, see UUID.version().
    Since:
    3.0
    Author:
    Patrick Taylor
    See Also:
    UUID, Serialized Form
    • Field Detail

      • EMPTY

        public static final Guid EMPTY
        A read-only Guid instance whose value is all zeros.
    • Constructor Detail

      • Guid

        public Guid()
        Constructs a new Guid.
        Since:
        3.0
      • Guid

        public Guid​(String guid)
        Constructs a new Guid using the specified guid string representation as described in the toString() method.
        Parameters:
        guid - a string that specifies a Guid.
        Throws:
        IllegalArgumentException - if guid does not conform to the string representation of a Guid as described in toString().
        Since:
        3.0
    • Method Detail

      • parseGuid

        public static Guid parseGuid​(String guid)
        Constructs a new Guid using the specified guid string representation as described in the toString() method.
        Parameters:
        guid - a string that specifies a Guid.
        Returns:
        a Guid with the specified value.
        Throws:
        IllegalArgumentException - if guid does not conform to the string representation of a Guid as described in toString().
        Since:
        3.0
      • isGuid

        public static boolean isGuid​(String guid)
        Tells whether or not the supplied guid string corresponds to a valid Guid.
        Parameters:
        guid - a string that specifies a Guid.
        Returns:
        true if guid corresponds to a valid Guid, false otherwise.
        Since:
        3.0
      • equals

        public boolean equals​(Object obj)
        Compares this object to the supplied object. The result is true if the argument it not null, it is of type Guid and it contains the same value as this Guid.
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare with.
        Returns:
        true if the objects are the same, false otherwise
        Since:
        3.0
      • hashCode

        public int hashCode()
        Returns a hash code for this Guid.
        Overrides:
        hashCode in class Object
        Returns:
        a hash code for this Guid.
        Since:
        3.0
      • toString

        public String toString()
        Returns a String representation of this Guid. The Guid string representation is on the following format, where x represents a hexadecimal ([0-9][a-f][A-F]) digit, "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
        The returned string is always in lower case.
        Overrides:
        toString in class Object
        Returns:
        a String representation of this Guid.
        Since:
        3.0
        See Also:
        UUID.toString()