@Test public void convertToLowerCase() { assertEquals(Dns.parse("example.com"), Dns.parse("EXAMPLE.com")); }
static Dns parse(String hostname) { int lastDot = -1; for (int i = 0; i < hostname.length(); i++) { char c = hostname.charAt(i); if (!DNS.matches(c)) { throw new InvalidHostException(hostname, i); } else if (c == '.') { if (lastDot == i - 1) { throw new InvalidHostException(hostname, i); } lastDot = i; } } String lower = hostname.toLowerCase(Locale.US); return new AutoValue_Dns(lower, IDN.toUnicode(lower)); }
Dns implements Host { static Dns parse(String hostname) { int lastDot = -1; for (int i = 0; i < hostname.length(); i++) { char c = hostname.charAt(i); if (!DNS.matches(c)) { throw new InvalidHostException(hostname, i); } else if (c == '.') { if (lastDot == i - 1) { throw new InvalidHostException(hostname, i); } lastDot = i; } } String lower = hostname.toLowerCase(Locale.US); return new AutoValue_Dns(lower, IDN.toUnicode(lower)); } }
Dns implements Host { static Dns parse(String hostname) { int lastDot = -1; for (int i = 0; i < hostname.length(); i++) { char c = hostname.charAt(i); if (!DNS.matches(c)) { throw new InvalidHostException(hostname, i); } else if (c == '.') { if (lastDot == i - 1) { throw new InvalidHostException(hostname, i); } lastDot = i; } } String lower = hostname.toLowerCase(Locale.US); return new AutoValue_Dns(lower, IDN.toUnicode(lower)); }  }
Dns implements Host { static Dns parse(String hostname) { int lastDot = -1; for (int i = 0; i < hostname.length(); i++) { char c = hostname.charAt(i); if (!DNS.matches(c)) { throw new InvalidHostException(hostname, i); } else if (c == '.') { if (lastDot == i - 1) { throw new InvalidHostException(hostname, i); } lastDot = i; } } String lower = hostname.toLowerCase(Locale.US); return new AutoValue_Dns(lower, IDN.toUnicode(lower)); }   }
Dns implements Host { static Dns parse(String hostname) { int lastDot = -1; for (int i = 0; i < hostname.length(); i++) { char c = hostname.charAt(i); if (!DNS.matches(c)) { throw new InvalidHostException(hostname, i); } else if (c == '.') { if (lastDot == i - 1) { throw new InvalidHostException(hostname, i); } lastDot = i; } } String lower = hostname.toLowerCase(Locale.US); return new AutoValue_Dns(lower, IDN.toUnicode(lower)); }    }