Package org.junit.platform.engine
Class UniqueId
- java.lang.Object
-
- org.junit.platform.engine.UniqueId
-
- All Implemented Interfaces:
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.SerializableUniqueIdencapsulates the creation, parsing, and display of unique IDs forTestDescriptors.Instances of this class have value semantics and are immutable.
- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUniqueId.SegmentA segment of aUniqueIdcomprises a type and a value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UniqueIdappend(java.lang.String segmentType, java.lang.String value)Construct a newUniqueIdby appending a newUniqueId.Segment, based on the suppliedsegmentTypeandvalue, to the end of thisUniqueId.UniqueIdappend(UniqueId.Segment segment)protected java.lang.Objectclone()booleanequals(java.lang.Object o)static UniqueIdforEngine(java.lang.String engineId)Create an engine's unique ID from itsengineIdusing the default format.java.util.Optional<java.lang.String>getEngineId()Get the engine ID stored in thisUniqueId, if available.UniqueId.SegmentgetLastSegment()Get the lastUniqueId.Segmentof thisUniqueId.java.util.List<UniqueId.Segment>getSegments()Get the immutable list of segments that make up thisUniqueId.inthashCode()booleanhasPrefix(UniqueId potentialPrefix)Determine if the suppliedUniqueIdis a prefix for thisUniqueId.static UniqueIdparse(java.lang.String uniqueId)Parse aUniqueIdfrom the supplied string representation using the default format.UniqueIdremoveLastSegment()static UniqueIdroot(java.lang.String segmentType, java.lang.String value)Create a root unique ID from the suppliedsegmentTypeandvalueusing the default format.java.lang.StringtoString()Generate the unique, formatted string representation of thisUniqueIdusing the configuredUniqueIdFormat.
-
-
-
Method Detail
-
parse
public static UniqueId parse(java.lang.String uniqueId) throws org.junit.platform.commons.JUnitException
Parse aUniqueIdfrom the supplied string representation using the default format.- Parameters:
uniqueId- the string representation to parse; nevernullor blank- Returns:
- a properly constructed
UniqueId - Throws:
org.junit.platform.commons.JUnitException- if the string cannot be parsed
-
forEngine
public static UniqueId forEngine(java.lang.String engineId)
Create an engine's unique ID from itsengineIdusing the default format.The engine ID will be stored in a
UniqueId.Segmentwithtype"engine".- Parameters:
engineId- the engine ID; nevernullor blank- See Also:
root(String, String)
-
root
public static UniqueId root(java.lang.String segmentType, java.lang.String value)
Create a root unique ID from the suppliedsegmentTypeandvalueusing the default format.- Parameters:
segmentType- the segment type; nevernullor blankvalue- the value; nevernullor blank- See Also:
forEngine(String)
-
getEngineId
public final java.util.Optional<java.lang.String> getEngineId()
Get the engine ID stored in thisUniqueId, if available.- See Also:
forEngine(String)
-
getSegments
public final java.util.List<UniqueId.Segment> getSegments()
Get the immutable list of segments that make up thisUniqueId.
-
append
public final UniqueId append(java.lang.String segmentType, java.lang.String value)
Construct a newUniqueIdby appending a newUniqueId.Segment, based on the suppliedsegmentTypeandvalue, to the end of thisUniqueId.This
UniqueIdwill not be modified.Neither the
segmentTypenor thevaluemay contain any of the special characters used for constructing the string representation of thisUniqueId.- Parameters:
segmentType- the type of the segment; nevernullor blankvalue- the value of the segment; nevernullor blank
-
append
@API(status=STABLE, since="1.1") public final UniqueId append(UniqueId.Segment segment)Construct a newUniqueIdby appending a newUniqueId.Segmentto the end of thisUniqueId.This
UniqueIdwill not be modified.- Parameters:
segment- the segment to be appended; nevernull- Since:
- 1.1
-
hasPrefix
@API(status=STABLE, since="1.1") public boolean hasPrefix(UniqueId potentialPrefix)Determine if the suppliedUniqueIdis a prefix for thisUniqueId.- Parameters:
potentialPrefix- theUniqueIdto be checked; nevernull- Since:
- 1.1
-
removeLastSegment
@API(status=STABLE, since="1.5") public UniqueId removeLastSegment()Construct a newUniqueIdand removing the lastUniqueId.Segmentof thisUniqueId.This
UniqueIdwill not be modified.- Returns:
- a new
UniqueId; nevernull - Throws:
org.junit.platform.commons.PreconditionViolationException- if thisUniqueIdcontains a single segment- Since:
- 1.5
-
getLastSegment
@API(status=STABLE, since="1.5") public UniqueId.Segment getLastSegment()Get the lastUniqueId.Segmentof thisUniqueId.- Returns:
- the last
Segment; nevernull - Since:
- 1.5
-
clone
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Generate the unique, formatted string representation of thisUniqueIdusing the configuredUniqueIdFormat.- Overrides:
toStringin classjava.lang.Object
-
-