UniqueId implements Comparable<UniqueId>, UniqueIdentifiable, ObjectIdentifiable, Serializable { @FromString public static UniqueId parse(String str) { ArgumentChecker.notEmpty(str, "str"); if (str.contains("~") == false) { str = StringUtils.replace(str, "::", "~"); } String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(str, "~"); switch (split.length) { case 2: return UniqueId.of(split[0], split[1], null); case 3: return UniqueId.of(split[0], split[1], split[2]); } throw new IllegalArgumentException("Invalid identifier format: " + str); } private  UniqueId(String scheme, String value, String version); static UniqueId of(String scheme, String value); static UniqueId of(String scheme, String value, String version); static UniqueId of(ObjectId objectId, String version); static UniqueId of(ExternalId externalId); @FromString static UniqueId parse(String str); String getScheme(); String getValue(); String getVersion(); UniqueId withScheme(final String scheme); UniqueId withValue(final String value); UniqueId withVersion(final String version); @Override ObjectId getObjectId(); @Override UniqueId getUniqueId(); boolean isLatest(); boolean isVersioned(); UniqueId toLatest(); ExternalId toExternalId(); boolean equalObjectId(ObjectIdentifiable other); @Override int compareTo(UniqueId other); @Override boolean equals(Object obj); @Override int hashCode(); @Override @ToString String toString(); @Deprecated void toFudgeMsg(final FudgeSerializer serializer, final MutableFudgeMsg msg); @Deprecated static UniqueId fromFudgeMsg(final FudgeDeserializer deserializer, final FudgeMsg msg); static final ExternalScheme EXTERNAL_SCHEME; }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_parse_invalidFormat1() { UniqueId.parse("Scheme"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_parse_invalidFormat2() { UniqueId.parse("Scheme:value"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_parse_invalidFormat3() { UniqueId.parse("Scheme~value~version~other"); }