Package org.drasyl.util
Class InetSocketAddressUtil
java.lang.Object
org.drasyl.util.InetSocketAddressUtil
Utility class for operations on
URL
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Checks equality ofa
andb
.static InetSocketAddress
replaceSocketAddressPort
(InetSocketAddress address, int port) static InetSocketAddress
resolve
(InetSocketAddress address) static InetSocketAddress
Convert aString
to aInetSocketAddress
.static String
Convert aInetSocketAddress
to aString
.
-
Method Details
-
socketAddressFromString
- Parameters:
s
- address to deserialize- Returns:
InetSocketAddress
representation ofs
-
socketAddressToString
- Parameters:
s
- address to deserialize- Returns:
String
representation ofs
-
equalSocketAddress
public static boolean equalSocketAddress(@NonNull InetSocketAddress a, @NonNull InetSocketAddress b) Checks equality ofa
andb
. In comparison toInetSocketAddress.equals(Object)
, this method can also compare resolved with unresolved addresses.- Parameters:
a
- first address to checkb
- second address to check- Returns:
true
if both addresses are equal
-
resolve
public static InetSocketAddress resolve(@NonNull InetSocketAddress address) throws UnknownHostException Resolvesaddress
and returns a newInetSocketAddress
with resolvedInetAddress
. Ifaddress
is already resolved, a new resolve attempt will be performed.- Parameters:
address
-InetSocketAddress
to be resolved- Returns:
- resolved
InetSocketAddress
- Throws:
UnknownHostException
- if resolve attempt failed
-
replaceSocketAddressPort
public static InetSocketAddress replaceSocketAddressPort(@NonNull InetSocketAddress address, int port)
-