class ExternalId implements ExternalIdentifiable, ExternalIdOrBundle, Comparable<ExternalId>, Serializable {

  @FromString
  public static ExternalId parse(String str) {
    ArgumentChecker.notEmpty(str, "str");
    str = StringUtils.replace(str, "::", "~");  // leniently parse old data
    int pos = str.indexOf("~");
    if (pos < 0) {
      throw new IllegalArgumentException("Invalid identifier format: " + str);
    }
    return new ExternalId(ExternalScheme.of(str.substring(0, pos)), str.substring(pos + 1));
  }

  private  ExternalId(ExternalScheme scheme, String value);

}