Enum IPVersionFilter

  • All Implemented Interfaces:
    Serializable, Comparable<IPVersionFilter>

    @ThreadSafe
    public enum IPVersionFilter
    extends Enum<IPVersionFilter>
    An enumeration that defines IP version filtering options for network connections. This filter can be used to restrict network connections to specific IP protocol versions.

    The filter supports three modes:

    • IPV4_AND_IPV6 - Allows both IPv4 and IPv6 addresses
    • IPV4 - Allows only IPv4 addresses
    • IPV6 - Allows only IPv6 addresses

    Example usage:

    
     IPVersionFilter filter = IPVersionFilter.IPV4;
     InetAddress address = InetAddress.getByName("192.168.1.1");
     if (filter.matches(address)) {
         // Address is allowed by the filter
     }
     
    • Enum Constant Detail

      • IPV4_AND_IPV6

        public static final IPVersionFilter IPV4_AND_IPV6
        Allows both IPv4 and IPv6 addresses. This is the most permissive filter option.
      • IPV4

        public static final IPVersionFilter IPV4
        Allows only IPv4 addresses. IPv6 addresses will be rejected by this filter.
      • IPV6

        public static final IPVersionFilter IPV6
        Allows only IPv6 addresses. IPv4 addresses will be rejected by this filter.
    • Method Detail

      • values

        public static IPVersionFilter[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (IPVersionFilter c : IPVersionFilter.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static IPVersionFilter valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • matches

        public boolean matches​(@Nullable
                               InetAddress address)
        Determines whether the given InetAddress matches this IP version filter.

        The matching logic is as follows:

        Parameters:
        address - the InetAddress to check against this filter.
        Returns:
        true if the address matches this filter's criteria, false otherwise (null will be false).
        See Also:
        Inet4Address, Inet6Address