@VisibleForTesting
    static int toMaskBits(String subnetMask) {
        int maskBits = 0;
        boolean expectZero = false;
        for (final String ipValue : dotSplitter.split(subnetMask)) {
            final int num = Integer.parseInt(ipValue);
            if (expectZero && num != 0) {
                throw new IllegalArgumentException("Invalid subnet mask address: " + subnetMask);
            }

            final int bits = ipDecimalToMaskBits.getOrDefault(num, -1);
            if (bits < 0) {
                throw new IllegalArgumentException("Invalid subnet mask address: " + subnetMask);
            }

            maskBits += bits;
            if (bits != 8 && !expectZero) {
                expectZero = true;
            }
        }
        return maskBits;
    }
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