Class NetworkAddress

java.lang.Object
space.arim.libertybans.api.NetworkAddress

public final class NetworkAddress extends Object
Lighter alternative to InetAddress specialised for handling the raw address, and not anything related to hostnames, etc.
Author:
A248
  • Method Details

    • of

      public static NetworkAddress of(InetAddress address)
      Creates from a InetAddress
      Parameters:
      address - the inet address
      Returns:
      the network address
      Throws:
      NullPointerException - if address is null
    • of

      public static NetworkAddress of(byte[] address)
      Creates from raw address bytes. For IPv4 addresses, this should be 4 bytes long, for IPv6, 16 bytes.

      Similar to InetAddress.getByAddress(byte[])
      Parameters:
      address - the raw address bytes, in network byte order
      Returns:
      the network address
      Throws:
      IllegalArgumentException - if the address bytes array is of illegal length
      NullPointerException - if address is null
    • getRawAddress

      public byte[] getRawAddress()
      Gets the raw address bytes of this network address
      Returns:
      the raw address
    • toInetAddress

      public InetAddress toInetAddress()
      Converts this network address to an equivalent InetAddress
      Returns:
      the inet address
    • hashCode

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

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Returns a textual representation of this network address
      Overrides:
      toString in class Object