class RouteDistinguisher implements Serializable, Comparable<RouteDistinguisher> {

  @Nonnull
  public static RouteDistinguisher parse(String value) {
    String[] arr = value.split(":");
    checkArgument(arr.length == 2, "At most one occurrence of ':' is allowed. Input was %s", value);
    // First element will dictate type of the route distinguisher
    Integer asn1 = Ints.tryParse(arr[0]);
    // If first element is a valid 2-byte int, it's a type 0
    if (asn1 != null && asn1 <= 0xFFFF) {
      return from(asn1, Long.parseUnsignedLong(arr[1]));
    }
    // If first element is a valid 4-byte int, it's a type 2
    Long asn1Long = Longs.tryParse(arr[0]);
    if (asn1Long != null) {
      return from(asn1Long, Integer.parseUnsignedInt(arr[1]));
    }
    // Finally fall back to trying to parse an IP address for type 1
    return from(Ip.parse(arr[0]), Integer.parseUnsignedInt(arr[1]));
  }

  private  RouteDistinguisher(long value, Type type);

}