ip-utils
A set of utility classes for working with IP addresses. Its most important features:
A lightweight IP address implementation
An IP address implementation that has the following advantages over InetAddress:
- It's very lightweight; for instance, it does not provide any functionality for hostname lookups or other functionality that requires network access.
- Its factory methods support the more generic CharSequence instead of only String.
- Its factory methods do not throw checked exceptions (like UnknownHostException).
- It supports native parsing to Optional without having to catch any exceptions.
- It supports native parsing to
byte[]
. - It supports native parsing with ParsePosition.
- It is Comparable.
To interact with existing code, it comes with bridge methods to convert to and from InetAddress. This allows you to replace most occurrences of InetAddress, Inet4Address and Inet6Address with IPAddress, IPv4Address and IPv6Address respectively.
Efficient IP range and subnet implementations
This library makes it possible to create an IP range from two IP addresses, or a subnet from a CIDR notation or an IP address and prefix length. This IP range or subnet is an immutable Collection of IP addresses with possibly thousands of elements, without the need to store all of these IP addresses.
Bean Validation support
The ip-validation library uses this library to provide validation constraints that work on both CharSequence and IPAddress. These not only allow you to validate that a value is a valid IP address, but also that the IP address is contained in a specific IP range or subnet.
JSON support
The ip-jackson-databind library provides support for serializing and deserializing IP addresses and ranges using Jackson.