Class CIDR


  • public final class CIDR
    extends java.lang.Object
    Contains a CIDR, and operations on it
    • Constructor Summary

      Constructors 
      Constructor Description
      CIDR​(java.net.InetAddress ipAddress, short netMask)
      Generates a CIDR from given IP and netmask
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String asCqlTupleString()  
      static int compareIPs​(java.net.InetAddress l, java.net.InetAddress r)
      Compare 2 IpAddresses objects lexicographically
      boolean equals​(java.lang.Object o)  
      java.net.InetAddress getEndIpAddress()
      Get ending IP of the CIDR
      static CIDR getInstance​(java.lang.String cidrStr)
      Generates a CIDR from given string
      short getNetMask()
      Get netmask of the CIDR
      java.net.InetAddress getStartIpAddress()
      Get starting IP of the CIDR
      int hashCode()  
      boolean isIPv4()
      Tells is this IPv4 format CIDR
      boolean isIPv6()
      Tells is this IPv6 format CIDR
      static boolean overlaps​(CIDR left, CIDR right)  
      java.lang.String toString()
      Constructs CIDR as string
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CIDR

        public CIDR​(java.net.InetAddress ipAddress,
                    short netMask)
        Generates a CIDR from given IP and netmask
        Parameters:
        ipAddress - IP address of CIDR
        netMask - netmask of CIDR
    • Method Detail

      • getInstance

        public static CIDR getInstance​(java.lang.String cidrStr)
        Generates a CIDR from given string
        Parameters:
        cidrStr - CIDR as string
      • getStartIpAddress

        public java.net.InetAddress getStartIpAddress()
        Get starting IP of the CIDR
        Returns:
        returns IP address
      • getEndIpAddress

        public java.net.InetAddress getEndIpAddress()
        Get ending IP of the CIDR
        Returns:
        returns IP address
      • getNetMask

        public short getNetMask()
        Get netmask of the CIDR
        Returns:
        returns netmask as short
      • isIPv4

        public boolean isIPv4()
        Tells is this IPv4 format CIDR
        Returns:
        true if IPv4 CIDR, otherwise false
      • isIPv6

        public boolean isIPv6()
        Tells is this IPv6 format CIDR
        Returns:
        true if IPv6 CIDR, otherwise false
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Constructs CIDR as string
        Overrides:
        toString in class java.lang.Object
        Returns:
        returns CIDR as string
      • asCqlTupleString

        public java.lang.String asCqlTupleString()
      • compareIPs

        public static int compareIPs​(java.net.InetAddress l,
                                     java.net.InetAddress r)
        Compare 2 IpAddresses objects lexicographically
        Returns:
        true if IP ranges overlap with each other; otherwise, return false
      • overlaps

        public static boolean overlaps​(CIDR left,
                                       CIDR right)