Pavlin Radoslavov

Removed method IpAddress.toInt(), because it is semantically incorrect:

It lacks the guarantee the underlying IP address is IPv4.

Potential users of toInt() should use Ip4Address.toInt()
or IpAddress.getIp4Address().toInt()
Tthe latter obviously might require the explicit check that
getIp4Address() is not null.

Change-Id: I3f939695cf3c496e3fdd3fbd4a2988b565cca69a
......@@ -125,17 +125,6 @@ public class IpAddress implements Comparable<IpAddress> {
}
/**
* Returns the integer value of this IP address.
* TODO: This method should be moved to Ip4Address.
*
* @return the IP address's value as an integer
*/
public int toInt() {
ByteBuffer bb = ByteBuffer.wrap(octets);
return bb.getInt();
}
/**
* Computes the IP address byte length for a given IP version.
*
* @param version the IP version
......
......@@ -175,23 +175,6 @@ public class IpAddressTest {
}
/**
* Tests returning an IPv4 address as an integer.
*/
@Test
public void testToInt() {
IpAddress ipAddress;
ipAddress = IpAddress.valueOf("1.2.3.4");
assertThat(ipAddress.toInt(), is(0x01020304));
ipAddress = IpAddress.valueOf("0.0.0.0");
assertThat(ipAddress.toInt(), is(0));
ipAddress = IpAddress.valueOf("255.255.255.255");
assertThat(ipAddress.toInt(), is(-1));
}
/**
* Tests valueOf() converter for IPv4 integer value.
*/
@Test
......