public List<InetAddress> addresses(String inetHost, ResolvedAddressTypes resolvedAddressTypes) {
        String normalized = normalize(inetHost);
        ensureHostsFileEntriesAreFresh();

        switch (resolvedAddressTypes) {
            case IPV4_ONLY:
                return inet4Entries.get(normalized);
            case IPV6_ONLY:
                return inet6Entries.get(normalized);
            case IPV4_PREFERRED:
                List<InetAddress> allInet4Addresses = inet4Entries.get(normalized);
                return allInet4Addresses != null ? allAddresses(allInet4Addresses, inet6Entries.get(normalized)) :
                        inet6Entries.get(normalized);
            case IPV6_PREFERRED:
                List<InetAddress> allInet6Addresses = inet6Entries.get(normalized);
                return allInet6Addresses != null ? allAddresses(allInet6Addresses, inet4Entries.get(normalized)) :
                        inet4Entries.get(normalized);
            default:
                throw new IllegalArgumentException("Unknown ResolvedAddressTypes " + resolvedAddressTypes);
        }
    }
@Test
    public void shouldntFindWhenAddressesTypeDoesntMatch() {
        HostsFileEntriesProvider.Parser parser = givenHostsParserWith(
                LOCALHOST_V4_ADDRESSES,
                Collections.<String, List<InetAddress>>emptyMap()
        );

        DefaultHostsFileEntriesResolver resolver = new DefaultHostsFileEntriesResolver(parser, ENTRIES_TTL);

        List<InetAddress> addresses = resolver.addresses("localhost", ResolvedAddressTypes.IPV6_ONLY);
        assertNull(addresses, "Should pick an IPv6 address");
    }