Skip to content
Snippets Groups Projects
Commit 52d14497 authored by Lucas Chiesa's avatar Lucas Chiesa Committed by Daniel Stonier
Browse files

Removed listAllInetAddress private method.

Also renamed getAllInetAddressByName to getAllInetAddressesByName.
parent d02c9244
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,13 @@ public class InetAddressFactory {
return address.getAddress().length == 4;
}
private static List<InetAddress> listAllInetAddress (Collection<NetworkInterface> networkInterfaces) {
private static Collection<InetAddress> getAllInetAddresses() {
List<NetworkInterface> networkInterfaces;
try {
networkInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
} catch (SocketException e) {
throw new RosRuntimeException(e);
}
List<InetAddress> inetAddresses = Lists.newArrayList();
for (NetworkInterface networkInterface : networkInterfaces) {
try {
......@@ -58,16 +64,6 @@ public class InetAddressFactory {
return inetAddresses;
}
private static Collection<InetAddress> getAllInetAddresses() {
List<NetworkInterface> networkInterfaces;
try {
networkInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
} catch (SocketException e) {
throw new RosRuntimeException(e);
}
return listAllInetAddress(networkInterfaces);
}
private static InetAddress filterInetAddresses (Collection<InetAddress> inetAddresses) {
for (InetAddress address : inetAddresses) {
// IPv4 only for now.
......@@ -86,7 +82,7 @@ public class InetAddressFactory {
return filterInetAddresses(Collections.list(networkInterface.getInetAddresses()));
}
private static Collection<InetAddress> getAllInetAddressByName(String host) {
private static Collection<InetAddress> getAllInetAddressesByName(String host) {
InetAddress[] allAddressesByName;
try {
allAddressesByName = org.xbill.DNS.Address.getAllByName(host);
......@@ -130,7 +126,7 @@ public class InetAddressFactory {
} catch (UnknownHostException e) {
throw new RosRuntimeException(e);
}
Collection<InetAddress> allAddressesByName = getAllInetAddressByName(host);
Collection<InetAddress> allAddressesByName = getAllInetAddressesByName(host);
// First, try to find a non-loopback IPv4 address.
for (InetAddress address : allAddressesByName) {
if (!address.isLoopbackAddress() && isIpv4(address)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment