public static boolean allIpAddressesValid(String ipAddresses) {

        if (!Strings.isNullOrEmpty(ipAddresses)) {
            return Lists.newArrayList(Splitter.on(",")
                                              .trimResults()
                                              .omitEmptyStrings()
                                              .split(ipAddresses)).stream()
                        .map(hostAndPort -> HostAndPort.fromString(hostAndPort).withDefaultPort(DnsClient.DEFAULT_DNS_PORT))
                        .allMatch(hostAndPort -> isValidIpAddress(hostAndPort.getHost()));
        }

        return false;
    }
@Test
    public void testValidCommaSeparatedIps() {

        assertTrue(DnsClient.allIpAddressesValid("8.8.4.4:53, 8.8.8.8")); // Custom port.
        assertTrue(DnsClient.allIpAddressesValid("8.8.4.4, ")); // Extra comma
        assertTrue(DnsClient.allIpAddressesValid("8.8.4.4")); // Pure IP
        assertFalse(DnsClient.allIpAddressesValid("8.8.4.4dfs:53, 8.8.4.4:59")); // Not an IP address
        assertFalse(DnsClient.allIpAddressesValid("8.8.4.4 8.8.8.8")); // No comma separator
        assertFalse(DnsClient.allIpAddressesValid("8.8.4.4, google.com")); // Hostname is not an IP address
    }