Class IPv6AddressRange

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<IPv6AddressRange>, java.lang.Iterable<IPv6Address>
    Direct Known Subclasses:
    IPv6Network

    public class IPv6AddressRange
    extends java.lang.Object
    implements java.lang.Comparable<IPv6AddressRange>, java.lang.Iterable<IPv6Address>, java.io.Serializable
    Immutable representation of a continuous range of IPv6 addresses (bounds included).
    See Also:
    Serialized Form
    • Method Detail

      • contains

        public boolean contains​(IPv6Address address)
      • iterator

        public java.util.Iterator<IPv6Address> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<IPv6Address>
        Returns:
        an iterator which iterates all addresses in this range, in order.
      • size

        public java.math.BigInteger size()
        Returns:
        number of addresses in the range
      • toSubnets

        public java.util.Iterator<IPv6Network> toSubnets()
        Deaggregate a range of IPv6 addresses (which is not necessarily aligned with a single IPv6 network) into a minimal set of non overlapping consecutive subnets.
        Returns:
        iterator of IPv6 networks that all together define the minimal set of subnets by which the range can be represented.
      • remove

        public java.util.List<IPv6AddressRange> remove​(IPv6Address address)
        Remove an address from the range, resulting in one, none or two new ranges. If an address outside the range is removed, this has no effect. If the first or last address is removed, a single new range is returned (potentially empty if the range only contained a single address). If an address somewhere else in the range is removed, two new ranges are returned.
        Parameters:
        address - adddress to remove from the range
        Returns:
        list of resulting ranges
      • extend

        public IPv6AddressRange extend​(IPv6Address address)
        Extend the range just enough at its head or tail such that the given address is included.
        Parameters:
        address - address to extend the range to
        Returns:
        new (bigger) range
      • remove

        public java.util.List<IPv6AddressRange> remove​(IPv6Network network)
        Remove a network from the range, resulting in one, none or two new ranges. If a network outside (or partially outside) the range is removed, this has no effect. If the network which is removed is aligned with the beginning or end of the range, a single new ranges is returned (potentially empty if the range was equal to the network which is removed from it). If a network somewhere else in the range is removed, two new ranges are returned.
        Parameters:
        network - network to remove from the range
        Returns:
        list of resulting ranges
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toLongString

        public java.lang.String toLongString()
        Returns:
        like toString but without using shorthand notations for addresses
      • compareTo

        public int compareTo​(IPv6AddressRange that)
        The natural order of IPv6AddressRanges orders them on increasing first addresses, and on increasing last address if the first address would be equal.

        Note that the natural order does thus not compare sizes of ranges.

        Specified by:
        compareTo in interface java.lang.Comparable<IPv6AddressRange>
        Parameters:
        that - range to compare with
        Returns:
        negative, zero or positive depending on whether this is smaller, equal or greater than that
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object