class PID implements Serializable {

  public static PID fromString(String pid) throws IllegalArgumentException {
    List<String> components = Splitter.on("@").omitEmptyStrings().splitToList(pid);
    if (components.size() != 2) {
      throw new IllegalArgumentException(
          "Illegal libprocess pid: " + pid + ". Format is id@host:port.");
    }
    String id = components.get(0);
    if (CharMatcher.WHITESPACE.matchesAnyOf(id)) {
      throw new IllegalArgumentException("No whitespace allowed in process id.");
    }
    HostAndPort hostAndPort = HostAndPort.fromString(components.get(1))
        .requireBracketsForIPv6();
    if (!hostAndPort.hasPort()) {
      throw new IllegalArgumentException("No port specified.");
    }
    return new PID(id, hostAndPort);
  }

  public  PID(String id, HostAndPort hostAndPort);

}