Home / Function/ sortAndFilter() — netty Function Reference

sortAndFilter() — netty Function Reference

Architecture documentation for the sortAndFilter() function in IpSubnetFilter.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  971c3ecb_dbe2_73b5_5309_fbca0e2a2df3["sortAndFilter()"]
  639d6b66_d0e8_891b_e1a9_3afd71f59c8a["IpSubnetFilter"]
  971c3ecb_dbe2_73b5_5309_fbca0e2a2df3 -->|defined in| 639d6b66_d0e8_891b_e1a9_3afd71f59c8a
  97dafcdf_024d_373a_bbbc_bb5d73ab52c5["IpSubnetFilter()"]
  97dafcdf_024d_373a_bbbc_bb5d73ab52c5 -->|calls| 971c3ecb_dbe2_73b5_5309_fbca0e2a2df3
  style 971c3ecb_dbe2_73b5_5309_fbca0e2a2df3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ipfilter/IpSubnetFilter.java lines 199–225

    @SuppressWarnings("ZeroLengthArrayAllocation")
    private static IpSubnetFilterRule[] sortAndFilter(List<IpSubnetFilterRule> rules) {
        Collections.sort(rules);
        Iterator<IpSubnetFilterRule> iterator = rules.iterator();
        List<IpSubnetFilterRule> toKeep = new ArrayList<IpSubnetFilterRule>();

        IpSubnetFilterRule parentRule = iterator.hasNext() ? iterator.next() : null;
        if (parentRule != null) {
            toKeep.add(parentRule);
        }

        while (iterator.hasNext()) {

            // Grab a potential child rule.
            IpSubnetFilterRule childRule = iterator.next();

            // If parentRule matches childRule, then there's no need to keep the child rule.
            // Otherwise, the rules are distinct and we need both.
            if (!parentRule.matches(new InetSocketAddress(childRule.getIpAddress(), 1))) {
                toKeep.add(childRule);
                // Then we'll keep the child rule around as the parent for the next round.
                parentRule = childRule;
            }
        }

        return toKeep.toArray(new IpSubnetFilterRule[0]);
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does sortAndFilter() do?
sortAndFilter() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ipfilter/IpSubnetFilter.java.
Where is sortAndFilter() defined?
sortAndFilter() is defined in handler/src/main/java/io/netty/handler/ipfilter/IpSubnetFilter.java at line 199.
What calls sortAndFilter()?
sortAndFilter() is called by 1 function(s): IpSubnetFilter.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free