@Override
    public int compare(InetSocketAddress addr1, InetSocketAddress addr2) {
        if (addr1.equals(addr2)) {
            return 0;
        }
        if (!addr1.isUnresolved() && !addr2.isUnresolved()) {
            if (addr1.getAddress().getClass() == addr2.getAddress().getClass()) {
                return 0;
            }
            return preferredAddressType.isAssignableFrom(addr1.getAddress().getClass()) ? -1 : 1;
        }
        if (addr1.isUnresolved() && addr2.isUnresolved()) {
            return 0;
        }
        return addr1.isUnresolved() ? 1 : -1;
    }
@Test
    public void testCompareUnresolvedSimple() {
        NameServerComparator comparator = new NameServerComparator(Inet4Address.class);
        int x = comparator.compare(IPV4ADDRESS1, UNRESOLVED1);
        int y = comparator.compare(UNRESOLVED1, IPV4ADDRESS1);

        assertEquals(-1, x);
        assertEquals(x, -y);
        assertEquals(0, comparator.compare(IPV4ADDRESS1, IPV4ADDRESS1));
        assertEquals(0, comparator.compare(UNRESOLVED1, UNRESOLVED1));
    }