类 HostPort
- java.lang.Object
-
- net.dongliu.commons.net.HostPort
-
public class HostPort extends java.lang.ObjectHost and Port for a net address
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 intensurePort()If has port, return port; else throw IllegalStateExceptionbooleanequals(java.lang.Object o)inthashCode()booleanhasPort()If has port partjava.lang.Stringhost()The host part of addressstatic HostPortof(java.lang.String host)Construct a HostPort with only hoststatic HostPortof(java.lang.String host, int port)Construct a HostPort with host and portstatic HostPortparse(java.lang.String address)Parse net address, return HostPort.java.util.OptionalIntport()The port part of addressjava.lang.StringtoString()java.lang.StringtoStringWithDefault(int defaultPort)Convert to String representation.java.lang.StringtoStringWithPort(int defaultPort)Convert to String representation with port part.HostTypetype()the typeHostPortwithPort(int port)Return a new HostPort with new port
-
-
-
方法详细资料
-
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
-
-