Package com.spotfire.server.util
Class Guid
- java.lang.Object
-
- com.spotfire.server.util.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), seeUUID
. 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 generatedUUID
, i.e., anUUID
of version type 4, seeUUID.version()
.- Since:
- 3.0
- Author:
- Patrick Taylor
- See Also:
UUID
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Guid()
Constructs a newGuid
.Guid(String guid)
Constructs a newGuid
using the specified guid string representation as described in thetoString()
method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Compares this object to the supplied object.int
hashCode()
Returns a hash code for thisGuid
.static boolean
isGuid(String guid)
Tells whether or not the supplied guid string corresponds to a validGuid
.static Guid
parseGuid(String guid)
Constructs a newGuid
using the specified guid string representation as described in thetoString()
method.String
toString()
Returns aString
representation of thisGuid
.
-
-
-
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 newGuid
.- Since:
- 3.0
-
Guid
public Guid(String guid)
Constructs a newGuid
using the specified guid string representation as described in thetoString()
method.- Parameters:
guid
- a string that specifies aGuid
.- Throws:
IllegalArgumentException
- if guid does not conform to the string representation of aGuid
as described intoString()
.- Since:
- 3.0
-
-
Method Detail
-
parseGuid
public static Guid parseGuid(String guid)
Constructs a newGuid
using the specified guid string representation as described in thetoString()
method.- Parameters:
guid
- a string that specifies aGuid
.- Returns:
- a
Guid
with the specified value. - Throws:
IllegalArgumentException
- if guid does not conform to the string representation of aGuid
as described intoString()
.- Since:
- 3.0
-
isGuid
public static boolean isGuid(String guid)
Tells whether or not the supplied guid string corresponds to a validGuid
.- Parameters:
guid
- a string that specifies aGuid
.- Returns:
true
if guid corresponds to a validGuid
,false
otherwise.- Since:
- 3.0
-
equals
public boolean equals(Object obj)
Compares this object to the supplied object. The result istrue
if the argument it notnull
, it is of typeGuid
and it contains the same value as thisGuid
.
-
hashCode
public int hashCode()
Returns a hash code for thisGuid
.
-
toString
public String toString()
Returns aString
representation of thisGuid
. TheGuid
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 classObject
- Returns:
- a
String
representation of thisGuid
. - Since:
- 3.0
- See Also:
UUID.toString()
-
-