Class HostAndPort

  • All Implemented Interfaces:
    SerializableObject

    public class HostAndPort
    extends java.lang.Object
    implements SerializableObject
    This class holds a easy IP/Hostname and port configuration for a server or a client bind address
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String host
      The host address which is configured by the constructors The host string can be an IPv4, IPv6 and a string
      protected int port
      The port is the port where the object is bound on
    • Field Detail

      • host

        protected java.lang.String host
        The host address which is configured by the constructors The host string can be an IPv4, IPv6 and a string
      • port

        protected int port
        The port is the port where the object is bound on
    • Constructor Detail

      • HostAndPort

        @Deprecated
        public HostAndPort​(java.net.SocketAddress socketAddress)
        Deprecated.
        unsafe, doesn't work with IPv6-addresses because they contain ":", use fromSocketAddress(SocketAddress) instead
      • HostAndPort

        public HostAndPort​(java.net.InetSocketAddress socketAddress)
      • HostAndPort

        public HostAndPort​(java.lang.String host,
                           int port)
      • HostAndPort

        public HostAndPort()
    • Method Detail

      • fromSocketAddress

        public static HostAndPort fromSocketAddress​(java.net.SocketAddress socketAddress)
        Tries to cast the provided socketAddress to an InetSocketAddress and returns a new HostAndPort based on it
        Parameters:
        socketAddress - the socketAddress to get a new HostAndPort instance from
        Returns:
        a new HostAndPort instance
        Throws:
        java.lang.IllegalArgumentException - if the provided socketAddress isn't instanceof InetSocketAddress
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getHost

        public java.lang.String getHost()
      • getPort

        public int getPort()