类 HostPort


  • public class HostPort
    extends java.lang.Object
    Host and Port for a net address
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      int ensurePort()
      If has port, return port; else throw IllegalStateException
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      boolean hasPort()
      If has port part
      java.lang.String host()
      The host part of address
      static HostPort of​(java.lang.String host)
      Construct a HostPort with only host
      static HostPort of​(java.lang.String host, int port)
      Construct a HostPort with host and port
      static HostPort parse​(java.lang.String address)
      Parse net address, return HostPort.
      java.util.OptionalInt port()
      The port part of address
      java.lang.String toString()  
      java.lang.String toStringWithDefault​(int defaultPort)
      Convert to String representation.
      java.lang.String toStringWithPort​(int defaultPort)
      Convert to String representation with port part.
      HostType type()
      the type
      HostPort withPort​(int port)
      Return a new HostPort with new port
      • 从类继承的方法 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 方法详细资料

      • of

        public static HostPort of​(java.lang.String host)
        Construct a HostPort with only host
      • of

        public static HostPort of​(java.lang.String host,
                                  int port)
        Construct a HostPort with host and port
      • parse

        public static HostPort parse​(java.lang.String address)
        Parse net address, return HostPort.
        抛出:
        java.lang.IllegalArgumentException - if address is not illegal
      • withPort

        public HostPort withPort​(int port)
        Return a new HostPort with new port
      • type

        public HostType type()
        the type
      • host

        public java.lang.String host()
        The host part of address
      • hasPort

        public boolean hasPort()
        If has port part
      • ensurePort

        public int ensurePort()
        If has port, return port; else throw IllegalStateException
        抛出:
        java.lang.IllegalStateException - if port is not set
      • port

        public java.util.OptionalInt port()
        The port part of address
      • equals

        public boolean equals​(java.lang.Object o)
        覆盖:
        equals 在类中 java.lang.Object
      • hashCode

        public int hashCode()
        覆盖:
        hashCode 在类中 java.lang.Object
      • toStringWithDefault

        public java.lang.String toStringWithDefault​(int defaultPort)
        Convert to String representation. If HostPort do not has port, or port equals default port, the returned string do not has port part.
      • toStringWithPort

        public java.lang.String toStringWithPort​(int defaultPort)
        Convert to String representation with port part. If HostPort do not has port, using default port.
      • toString

        public java.lang.String toString()
        覆盖:
        toString 在类中 java.lang.Object