private static Predicate<InetAddress> ofCidr(InetAddress baseAddress,
                                                 int inet4MaskBits,
                                                 int inet6MaskBits) {
        if (baseAddress instanceof Inet4Address) {
            return new Inet4AddressBlock((Inet4Address) baseAddress, inet4MaskBits);
        }
        if (baseAddress instanceof Inet6Address) {
            final byte[] bytes = ipv6ToIpv4Address((Inet6Address) baseAddress);
            if (bytes == null) {
                return new Inet6AddressBlock((Inet6Address) baseAddress, inet6MaskBits);
            }

            try {
                final Inet4Address inet4Address = (Inet4Address) InetAddress.getByAddress(bytes);
                return new Inet4AddressBlock(inet4Address, inet6MaskBits - 96);
            } catch (UnknownHostException e) {
                throw new IllegalArgumentException("Invalid address: " + baseAddress.getHostAddress(), e);
            }
        }
        throw new IllegalArgumentException(
                "Unknown baseAddress type: " + baseAddress.getClass().getName() +
                " (expected: " + Inet4Address.class.getSimpleName() +
                " or " + Inet6Address.class.getSimpleName() + ')');
    }
Returns a {@link Predicate} which returns {@code true} if the given {@link InetAddress} is in the
range of a <a href="https://datatracker.ietf.org/doc/rfc4632/">Classless Inter-domain Routing (CIDR)</a> block.

@param cidr the CIDR notation of an address block, e.g. {@code 10.0.0.0/8}, {@code 192.168.1.0/24},
            {@code 1080:0:0:0:8:800:200C:4100/120}. If it's an exact IP address such as
            {@code 10.1.1.7} or {@code 1080:0:0:0:8:800:200C:4100}, the mask bits is considered as
            {@code 32} for IPv4 or {@code 128} for IPv6.
core/src/main/java/com/linecorp/armeria/common/util/InetAddressPredicates.java