@Test public void idnEqualsTest() { assertTrue(NameUtil.idnEquals(null, null)); assertTrue(NameUtil.idnEquals("domain.example", "domain.example")); assertTrue(NameUtil.idnEquals("dömäin.example", "xn--dmin-moa0i.example")); assertTrue(NameUtil.idnEquals("موقع.وزارة-الاتصالات.مصر", "xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c")); assertFalse(NameUtil.idnEquals("dömäin.example", null)); assertFalse(NameUtil.idnEquals(null, "domain.example")); assertFalse(NameUtil.idnEquals("dömäin.example", "domain.example")); assertFalse(NameUtil.idnEquals("", "domain.example")); }
@SuppressWarnings("ReferenceEquality") public static boolean idnEquals(String name1, String name2) { if (name1 == name2) return true; if (name1 == null) return false; if (name2 == null) return false; if (name1.equals(name2)) return true; return DnsName.from(name1).compareTo(DnsName.from(name2)) == 0; }
NameUtil { @SuppressWarnings("ReferenceEquality") public static boolean idnEquals(String name1, String name2) { if (name1 == name2) return true; if (name1 == null) return false; if (name2 == null) return false; if (name1.equals(name2)) return true; return DnsName.from(name1).compareTo(DnsName.from(name2)) == 0; } }
NameUtil { @SuppressWarnings("ReferenceEquality") public static boolean idnEquals(String name1, String name2) { if (name1 == name2) return true; if (name1 == null) return false; if (name2 == null) return false; if (name1.equals(name2)) return true; return DnsName.from(name1).compareTo(DnsName.from(name2)) == 0; }  }
NameUtil { @SuppressWarnings("ReferenceEquality") public static boolean idnEquals(String name1, String name2) { if (name1 == name2) return true; if (name1 == null) return false; if (name2 == null) return false; if (name1.equals(name2)) return true; return DnsName.from(name1).compareTo(DnsName.from(name2)) == 0; }  @SuppressWarnings("ReferenceEquality") static boolean idnEquals(String name1, String name2); }
NameUtil { @SuppressWarnings("ReferenceEquality") public static boolean idnEquals(String name1, String name2) { if (name1 == name2) return true; if (name1 == null) return false; if (name2 == null) return false; if (name1.equals(name2)) return true; return DnsName.from(name1).compareTo(DnsName.from(name2)) == 0; }  @SuppressWarnings("ReferenceEquality") static boolean idnEquals(String name1, String name2);  }