java.io.Serializable
, java.lang.Cloneable
@API(status=STABLE, since="1.0") public class UniqueId extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
UniqueId
encapsulates the creation, parsing, and display of unique IDs
for TestDescriptors
.
Instances of this class have value semantics and are immutable.
Modifier and Type | Class | Description |
---|---|---|
static class |
UniqueId.Segment |
A segment of a
UniqueId comprises a type and a
value. |
Modifier and Type | Method | Description |
---|---|---|
UniqueId |
append(java.lang.String segmentType,
java.lang.String value) |
Construct a new
UniqueId by appending a new UniqueId.Segment , based
on the supplied segmentType and value , to the end of this
UniqueId . |
protected java.lang.Object |
clone() |
|
boolean |
equals(java.lang.Object o) |
|
static UniqueId |
forEngine(java.lang.String engineId) |
Create an engine's unique ID from its
engineId using the default
format. |
java.util.Optional<java.lang.String> |
getEngineId() |
Get the engine ID stored in this
UniqueId , if available. |
java.util.List<UniqueId.Segment> |
getSegments() |
Get the immutable list of segments that make up this
UniqueId . |
int |
hashCode() |
|
static UniqueId |
parse(java.lang.String uniqueId) |
Parse a
UniqueId from the supplied string representation using the
default format. |
static UniqueId |
root(java.lang.String segmentType,
java.lang.String value) |
Create a root unique ID from the supplied
segmentType and
value using the default format. |
java.lang.String |
toString() |
Generate the unique, formatted string representation of this
UniqueId
using the configured UniqueIdFormat . |
public static UniqueId parse(java.lang.String uniqueId) throws JUnitException
UniqueId
from the supplied string representation using the
default format.uniqueId
- the string representation to parse; never null
or blankUniqueId
JUnitException
- if the string cannot be parsedpublic static UniqueId forEngine(java.lang.String engineId)
engineId
using the default
format.
The engine ID will be stored in a UniqueId.Segment
with
type
"engine"
.
engineId
- the engine ID; never null
or blankroot(String, String)
public static UniqueId root(java.lang.String segmentType, java.lang.String value)
segmentType
and
value
using the default format.segmentType
- the segment type; never null
or blankvalue
- the value; never null
or blankforEngine(String)
public final java.util.Optional<java.lang.String> getEngineId()
UniqueId
, if available.forEngine(String)
public final java.util.List<UniqueId.Segment> getSegments()
UniqueId
.public final UniqueId append(java.lang.String segmentType, java.lang.String value)
UniqueId
by appending a new UniqueId.Segment
, based
on the supplied segmentType
and value
, to the end of this
UniqueId
.
This UniqueId
will not be modified.
Neither the segmentType
nor the value
may contain any
of the special characters used for constructing the string representation
of this UniqueId
.
segmentType
- the type of the segment; never null
or blankvalue
- the value of the segment; never null
or blankprotected java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
UniqueId
using the configured UniqueIdFormat
.toString
in class java.lang.Object