@API(value=Experimental) public class UniqueId extends Object implements Cloneable, 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 and Description |
---|---|
static class |
UniqueId.Segment
A segment of a
UniqueId comprises a type and a
value. |
Modifier and Type | Method and Description |
---|---|
UniqueId |
append(String segmentType,
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 Object |
clone() |
boolean |
equals(Object o) |
static UniqueId |
forEngine(String engineId)
Create an engine's unique ID from its
engineId using the default
format. |
Optional<String> |
getEngineId()
Get the engine ID stored in this
UniqueId , if available. |
List<UniqueId.Segment> |
getSegments()
Get the immutable list of segments that make up this
UniqueId . |
int |
hashCode() |
static UniqueId |
parse(String uniqueId)
Parse a
UniqueId from the supplied string representation using the
default format. |
static UniqueId |
root(String segmentType,
String value)
Create a root unique ID from the supplied
segmentType and
value using the default format. |
String |
toString()
Generate the unique, formatted string representation of this
UniqueId
using the configured UniqueIdFormat . |
public static UniqueId parse(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(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(String segmentType, 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 Optional<String> getEngineId()
UniqueId
, if available.forEngine(String)
public final List<UniqueId.Segment> getSegments()
UniqueId
.public final UniqueId append(String segmentType, 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 Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException