generated from mingliqiye/lib-tem
no message
This commit is contained in:
parent
76f2581a9f
commit
2a15ab653f
@ -1,5 +1,5 @@
|
||||
GROUPSID=com.mingliqiye
|
||||
ARTIFACTID=network-endpoint
|
||||
VERSIONS=1.0.2
|
||||
VERSIONS=1.0.3
|
||||
MAINCLASS=com.mingliqiye
|
||||
JDKVERSIONS=1.8
|
||||
|
@ -56,12 +56,14 @@ public class NetworkAddress implements Serializable {
|
||||
public static NetworkAddress of(String domip) {
|
||||
return new NetworkAddress(domip);
|
||||
}
|
||||
|
||||
public static NetworkAddress of(InetAddress inetAddress) {
|
||||
return new NetworkAddress(inetAddress.getHostAddress());
|
||||
}
|
||||
public InetAddress toInetAddress(){
|
||||
|
||||
public InetAddress toInetAddress() {
|
||||
try {
|
||||
return InetAddress.getByName(domain);
|
||||
return InetAddress.getByName(ip != null ? ip : domain);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -74,7 +76,8 @@ public class NetworkAddress implements Serializable {
|
||||
* @return IP地址
|
||||
* @throws UnknownHostException 没找到对应的IP
|
||||
*/
|
||||
public static String getHostIp(@NotNull String domain) throws UnknownHostException {
|
||||
public static String getHostIp(@NotNull String domain)
|
||||
throws UnknownHostException {
|
||||
InetAddress[] addresses = InetAddress.getAllByName(domain.trim());
|
||||
return addresses[0].getHostAddress();
|
||||
}
|
||||
@ -110,9 +113,10 @@ public class NetworkAddress implements Serializable {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return isdom?StringUtil.format("NetworkAddress(IP='{}',type='{}'," +
|
||||
"domain='{}')",ip,IPv,domain):
|
||||
StringUtil.format("NetworkAddress(IP='{}',type='{}')",ip,IPv);
|
||||
return isdom ? StringUtil.format(
|
||||
"NetworkAddress(IP='{}',type='{}'," + "domain='{}')", ip, IPv,
|
||||
domain) :
|
||||
StringUtil.format("NetworkAddress(IP='{}',type='{}')", ip, IPv);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user