Returns a new InetAddress that is one less than the passed in address. This method works for both IPv4 and IPv6 addresses. @param address the InetAddress to decrement @return a new InetAddress that is one less than the passed in address @throws IllegalArgumentException if InetAddress is at the begi
(InetAddress address)
| 960 | |
| 961 | |
| 962 | public static InetAddress decrement(InetAddress address) { |
| 963 | byte[] addr = address.getAddress(); |
| 964 | int i = addr.length - 1; |
| 965 | while (i >= 0 && addr[i] == (byte) 0x00) { |
| 966 | addr[i] = (byte) 0xff; |
| 967 | i--; |
| 968 | } |
| 969 | Preconditions.checkArgument(i >= 0, "Decrementing %s would wrap.", address); |
| 970 | addr[i]--; |
| 971 | return bytesToInetAddress(addr); |
| 972 | } |
| 973 | |
| 974 | /** |
| 975 | * Returns a new InetAddress that is one more than the passed in address. This method works for |
nothing calls this directly
no test coverage detected