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> { ...@@ -125,17 +125,6 @@ public class IpAddress implements Comparable<IpAddress> {
125 } 125 }
126 126
127 /** 127 /**
128 - * Returns the integer value of this IP address.
129 - * TODO: This method should be moved to Ip4Address.
130 - *
131 - * @return the IP address's value as an integer
132 - */
133 - public int toInt() {
134 - ByteBuffer bb = ByteBuffer.wrap(octets);
135 - return bb.getInt();
136 - }
137 -
138 - /**
139 * Computes the IP address byte length for a given IP version. 128 * Computes the IP address byte length for a given IP version.
140 * 129 *
141 * @param version the IP version 130 * @param version the IP version
......
...@@ -175,23 +175,6 @@ public class IpAddressTest { ...@@ -175,23 +175,6 @@ public class IpAddressTest {
175 } 175 }
176 176
177 /** 177 /**
178 - * Tests returning an IPv4 address as an integer.
179 - */
180 - @Test
181 - public void testToInt() {
182 - IpAddress ipAddress;
183 -
184 - ipAddress = IpAddress.valueOf("1.2.3.4");
185 - assertThat(ipAddress.toInt(), is(0x01020304));
186 -
187 - ipAddress = IpAddress.valueOf("0.0.0.0");
188 - assertThat(ipAddress.toInt(), is(0));
189 -
190 - ipAddress = IpAddress.valueOf("255.255.255.255");
191 - assertThat(ipAddress.toInt(), is(-1));
192 - }
193 -
194 - /**
195 * Tests valueOf() converter for IPv4 integer value. 178 * Tests valueOf() converter for IPv4 integer value.
196 */ 179 */
197 @Test 180 @Test
......