Package org.junit.platform.engine
Class UniqueId
java.lang.Object
org.junit.platform.engine.UniqueId
- All Implemented Interfaces:
Serializable
,Cloneable
@API(status=STABLE,
since="1.0")
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.
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A segment of aUniqueId
comprises a type and a value. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private int
private final List
<UniqueId.Segment> private static final long
private String
private final UniqueIdFormat
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
UniqueId
(UniqueIdFormat uniqueIdFormat, List<UniqueId.Segment> segments) Initialize aUniqueId
instance.private
UniqueId
(UniqueIdFormat uniqueIdFormat, UniqueId.Segment segment) -
Method Summary
Modifier and TypeMethodDescriptionfinal UniqueId
Construct a newUniqueId
by appending a newUniqueId.Segment
, based on the suppliedsegmentType
andvalue
, to the end of thisUniqueId
.final UniqueId
append
(UniqueId.Segment segment) protected Object
clone()
boolean
static UniqueId
Create an engine's unique ID from itsengineId
using the default format.Get the engine ID stored in thisUniqueId
, if available.Get the lastUniqueId.Segment
of thisUniqueId
.(package private) final Optional
<UniqueId.Segment> getRoot()
final List
<UniqueId.Segment> Get the immutable list of segments that make up thisUniqueId
.int
hashCode()
boolean
Determine if the suppliedUniqueId
is a prefix for thisUniqueId
.static UniqueId
Parse aUniqueId
from the supplied string representation using the default format.static UniqueId
Create a root unique ID from the suppliedsegmentType
andvalue
using the default format.toString()
Generate the unique, formatted string representation of thisUniqueId
using the configuredUniqueIdFormat
.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ENGINE_SEGMENT_TYPE
- See Also:
-
uniqueIdFormat
-
segments
-
hashCode
private transient int hashCode -
toString
-
-
Constructor Details
-
UniqueId
-
UniqueId
UniqueId(UniqueIdFormat uniqueIdFormat, List<UniqueId.Segment> segments) Initialize aUniqueId
instance.
-
-
Method Details
-
parse
Parse aUniqueId
from the supplied string representation using the default format.- Parameters:
uniqueId
- the string representation to parse; nevernull
or blank- Returns:
- a properly constructed
UniqueId
- Throws:
JUnitException
- if the string cannot be parsed
-
forEngine
Create an engine's unique ID from itsengineId
using the default format.The engine ID will be stored in a
UniqueId.Segment
withtype
"engine"
.- Parameters:
engineId
- the engine ID; nevernull
or blank- See Also:
-
root
Create a root unique ID from the suppliedsegmentType
andvalue
using the default format.- Parameters:
segmentType
- the segment type; nevernull
or blankvalue
- the value; nevernull
or blank- See Also:
-
getRoot
-
getEngineId
Get the engine ID stored in thisUniqueId
, if available.- See Also:
-
getSegments
Get the immutable list of segments that make up thisUniqueId
. -
append
Construct a newUniqueId
by appending a newUniqueId.Segment
, based on the suppliedsegmentType
andvalue
, to the end of thisUniqueId
.This
UniqueId
will not be modified.Neither the
segmentType
nor thevalue
may contain any of the special characters used for constructing the string representation of thisUniqueId
.- Parameters:
segmentType
- the type of the segment; nevernull
or blankvalue
- the value of the segment; nevernull
or blank
-
append
Construct a newUniqueId
by appending a newUniqueId.Segment
to the end of thisUniqueId
.This
UniqueId
will not be modified.- Parameters:
segment
- the segment to be appended; nevernull
- Since:
- 1.1
-
hasPrefix
Determine if the suppliedUniqueId
is a prefix for thisUniqueId
.- Parameters:
potentialPrefix
- theUniqueId
to be checked; nevernull
- Since:
- 1.1
-
removeLastSegment
Construct a newUniqueId
and removing the lastUniqueId.Segment
of thisUniqueId
.This
UniqueId
will not be modified.- Returns:
- a new
UniqueId
; nevernull
- Throws:
PreconditionViolationException
- if thisUniqueId
contains a single segment- Since:
- 1.5
-
getLastSegment
Get the lastUniqueId.Segment
of thisUniqueId
.- Returns:
- the last
Segment
; nevernull
- Since:
- 1.5
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
equals
-
hashCode
public int hashCode() -
toString
Generate the unique, formatted string representation of thisUniqueId
using the configuredUniqueIdFormat
.
-