Record Class Inet.V4

java.lang.Object
java.lang.Record
io.codemine.java.postgresql.codecs.Inet.V4
Record Components:
address - IPv4 address as a 32-bit big-endian word.
netmask - Network mask length in the range 0–32.
All Implemented Interfaces:
Inet
Enclosing interface:
Inet

public static record Inet.V4(int address, byte netmask) extends Record implements Inet
IPv4 host address with optional subnet mask.
  • Constructor Details

    • V4

      public V4(int address, byte netmask)
      Creates an instance of a V4 record class.
      Parameters:
      address - the value for the address record component
      netmask - the value for the netmask record component
  • Method Details

    • of

      public static Inet.V4 of(Inet4Address addr)
      Creates an Inet.V4 from a Inet4Address with a full host netmask ( /32).
      Parameters:
      addr - the IPv4 address
    • toInetAddress

      public Inet4Address toInetAddress()
      Returns the address part of this value as a Inet4Address. The netmask is not represented in the returned object.
      Specified by:
      toInetAddress in interface Inet
    • appendInTextTo

      public void appendInTextTo(StringBuilder sb)
      Description copied from interface: Inet
      Appends the PostgreSQL text representation of this address to sb.
      Specified by:
      appendInTextTo in interface Inet
    • encodeInBinary

      public void encodeInBinary(ByteArrayOutputStream out)
      Description copied from interface: Inet
      Encodes this address in PostgreSQL binary wire format into out.
      Specified by:
      encodeInBinary in interface Inet
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • address

      public int address()
      Returns the value of the address record component.
      Returns:
      the value of the address record component
    • netmask

      public byte netmask()
      Returns the value of the netmask record component.
      Returns:
      the value of the netmask record component