Interface Range<A extends Address<A>>

Type Parameters:
A - address type
All Superinterfaces:
AddressSet<A>, Iterable<A>
All Known Subinterfaces:
Block<A>

public interface Range<A extends Address<A>> extends AddressSet<A>

AddressSet interface that forms contiguous range of one or more Addresses.

See AddressSet for implementation contract.

Implementations are always contiguous lists.

  • Method Details

    • first

      A first()
      Least element in the range.
      Returns:
      first
    • last

      A last()
      Greatest element in the range.
      Returns:
      last
    • ranges

      default Stream<Range<A>> ranges()
      Description copied from interface: AddressSet

      Constituent Ranges.

      Adjacent or overlapping ranges MUST be combined into a single Range. Elements MUST be produced from least Address to greatest.

      A Stream of Address values can be obtained with ranges().flatMap(Range::stream). A Stream of Blocks can be obtained with ranges().flatMap(Range::blocks).

      Specified by:
      ranges in interface AddressSet<A extends Address<A>>
      Returns:
      constituent ranges
    • size

      default BigInteger size()
      Number of Addresses in range.
      Specified by:
      size in interface AddressSet<A extends Address<A>>
      Returns:
      number of addresses including first() and last()
    • contains

      default boolean contains(Address<?> address)
      Tests argument is same Family and more than or equal to first() and less than or equal to last().
      Specified by:
      contains in interface AddressSet<A extends Address<A>>
      Parameters:
      address - the address to test
      Returns:
      true if this sequence contains the given IP address
    • iterator

      default Iterator<A> iterator()
      All addresses in the range.
      Specified by:
      iterator in interface Iterable<A extends Address<A>>
      Returns:
      from first to last
    • spliterator

      default Spliterator<A> spliterator()
      Specified by:
      spliterator in interface Iterable<A extends Address<A>>
      Returns:
      instance
    • stream

      default Stream<A> stream()
      All addresses in the range.
      Returns:
      from first to last
    • blocks

      default Stream<Block<A>> blocks()
      Streams arbitrary range as valid CIDR blocks.
      Returns:
      stream
    • contiguous

      default boolean contiguous(Range<A> r)
      Tests if this range can create a contiguous range with another. That is, either intersects(Range) or adjacent(Range) are true.
      Parameters:
      r - another range
      Returns:
      true if contiguous
    • intersects

      default boolean intersects(Range<A> r)
      Tests if there is any overlap in the address ranges.
      Parameters:
      r - another range
      Returns:
      true on intersection
    • adjacent

      default boolean adjacent(Range<A> r)
      Tests if the last value in either range is one less than the first value of the other.
      Parameters:
      r - another range
      Returns:
      true if adjacent
    • combine

      default Range<A> combine(Range<A> other)
      Combines two ranges into a single range using the least and greatest values from each. The ranges do not have to be contiguous - this is not a union method.
      Parameters:
      other - another range
      Returns:
      new range
      See Also: