Class CIDR

java.lang.Object
org.apache.cassandra.cql3.CIDR

public final class CIDR extends Object
Contains a CIDR, and operations on it
  • Constructor Details

    • CIDR

      public CIDR(InetAddress ipAddress, short netMask)
      Generates a CIDR from given IP and netmask
      Parameters:
      ipAddress - IP address of CIDR
      netMask - netmask of CIDR
  • Method Details

    • getInstance

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

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

      public 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(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

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

      public String asCqlTupleString()
    • compareIPs

      public static int compareIPs(InetAddress l, 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)