Class Ip

java.lang.Object
org.batfish.datamodel.Ip
All Implemented Interfaces:
Serializable, Comparable<Ip>

public class Ip extends Object implements Comparable<Ip>, Serializable
An IPv4 address
See Also:
  • Field Details

    • AUTO

      public static final Ip AUTO
    • FIRST_CLASS_A_PRIVATE_IP

      public static final Ip FIRST_CLASS_A_PRIVATE_IP
    • FIRST_CLASS_B_PRIVATE_IP

      public static final Ip FIRST_CLASS_B_PRIVATE_IP
    • FIRST_CLASS_C_PRIVATE_IP

      public static final Ip FIRST_CLASS_C_PRIVATE_IP
    • FIRST_CLASS_E_EXPERIMENTAL_IP

      public static final Ip FIRST_CLASS_E_EXPERIMENTAL_IP
    • FIRST_MULTICAST_IP

      public static final Ip FIRST_MULTICAST_IP
    • MAX

      public static final Ip MAX
    • ZERO

      public static final Ip ZERO
  • Method Details

    • getBitAtPosition

      public static boolean getBitAtPosition(Ip ip, int position)
      See getBitAtPosition(long, int). Equivalent to getBitAtPosition(ip.asLong(), position)
    • getBitAtPosition

      public static boolean getBitAtPosition(long bits, int position)
      Return the boolean value of a bit at the given position.
      Parameters:
      bits - the representation of an IP address as a long
      position - bit position (0 means most significant, 31 least significant)
      Returns:
      a boolean representation of the bit value
    • numSubnetBitsToSubnetMask

      public static Ip numSubnetBitsToSubnetMask(int numBits)
    • tryParse

      @Nonnull public static Optional<Ip> tryParse(@Nonnull String text)
      Return an Optional Ip from a string, or Optional.empty() if the string does not represent an Ip.
    • parse

      public static Ip parse(String ipAsString)
    • create

      public static Ip create(long ipAsLong)
    • asLong

      public long asLong()
    • compareTo

      public int compareTo(Ip rhs)
      Specified by:
      compareTo in interface Comparable<Ip>
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • getClassMask

      public Ip getClassMask()
    • getClassNetworkSize

      public int getClassNetworkSize()
      Returns the size of an IPv4 network in IPv4 Address Class of this Ip. Returns -1 if the class does not have a defined subnet size, e.g. the experimental subnet.
    • getNetworkAddress

      public Ip getNetworkAddress(int subnetBits)
    • hashCode

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

      public Ip inverted()
    • numSubnetBits

      public int numSubnetBits()
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • valid

      public boolean valid()
    • toPrefix

      public Prefix toPrefix()