Skip to content

Commit

Permalink
Removed listAllInetAddress private method.
Browse files Browse the repository at this point in the history
Also renamed getAllInetAddressByName to getAllInetAddressesByName.
  • Loading branch information
tulku authored and stonier committed Jun 27, 2014
1 parent d02c924 commit 52d1449
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions rosjava/src/main/java/org/ros/address/InetAddressFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ private static boolean isIpv4(InetAddress address) {
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 {
Expand All @@ -58,16 +64,6 @@ private static List<InetAddress> listAllInetAddress (Collection<NetworkInterface
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.
Expand All @@ -86,7 +82,7 @@ public static InetAddress newNonLoopbackForNetworkInterface(NetworkInterface net
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);
Expand Down Expand Up @@ -130,7 +126,7 @@ public static InetAddress newFromHostString(String host) {
} 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)) {
Expand Down

0 comments on commit 52d1449

Please sign in to comment.