private Segment createSegment(String segmentString) throws JUnitException { Matcher segmentMatcher = this.segmentPattern.matcher(segmentString); if (!segmentMatcher.matches()) { throw new JUnitException(String.format("'%s' is not a well-formed UniqueId segment", segmentString)); } String type = decode(checkAllowed(segmentMatcher.group(1))); String value = decode(checkAllowed(segmentMatcher.group(2))); return new Segment(type, value); }
/** * Construct a new {@code UniqueId} by appending a new {@link Segment}, based * on the supplied {@code segmentType} and {@code value}, to the end of this * {@code UniqueId}. * * <p>This {@code UniqueId} will not be modified. * * <p>Neither the {@code segmentType} nor the {@code value} may contain any * of the special characters used for constructing the string representation * of this {@code UniqueId}. * * @param segmentType the type of the segment; never {@code null} or blank * @param value the value of the segment; never {@code null} or blank */ public final UniqueId append(String segmentType, String value) { return append(new Segment(segmentType, value)); }
/** * Create a root unique ID from the supplied {@code segmentType} and * {@code value} using the default format. * * @param segmentType the segment type; never {@code null} or blank * @param value the value; never {@code null} or blank * @see #forEngine(String) */ public static UniqueId root(String segmentType, String value) { return new UniqueId(UniqueIdFormat.getDefault(), new Segment(segmentType, value)); }