Package uk.ipfreely.sets
Interface Range<A extends Addr<A>>
- Type Parameters:
A
- address type
- All Superinterfaces:
AddressSet<A>
,Iterable<A>
- All Known Subinterfaces:
Block<A>
AddressSet
interface that forms contiguous range of one or more Addr
es.
See AddressSet
for implementation contract.
Implementations are always contiguous lists.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Tests if the last value in either range is one less than the first value of the other.blocks()
Streams arbitrary range as valid CIDR blocks.Combines two ranges into a single range using the least and greatest values from each.default boolean
default boolean
contiguous
(Range<A> r) Tests if this range can create a contiguous range with another.family()
Convenience method.first()
Least element in the range.default boolean
intersects
(Range<A> r) Tests if there is any overlap in the address ranges.default boolean
isEmpty()
Range is never empty.iterator()
All addresses in the range.last()
Greatest element in the range.ranges()
ConstituentRange
s.default BigInteger
size()
Number ofAddr
es in range.default Spliterator
<A> stream()
All addresses in the range.Methods inherited from interface uk.ipfreely.sets.AddressSet
equals, hashCode
-
Method Details
-
first
A first()Least element in the range.- Returns:
- first
-
last
A last()Greatest element in the range.- Returns:
- last
-
family
Convenience method.- Returns:
- range family
-
ranges
Description copied from interface:AddressSet
Constituent
Range
s.Adjacent or overlapping ranges MUST be combined into a single
Range
. Elements MUST be produced from leastAddr
to greatest.A
Stream
ofAddr
values can be obtained withranges().flatMap(Range::stream)
. AStream
ofBlock
s can be obtained withranges().flatMap(Range::blocks)
.- Specified by:
ranges
in interfaceAddressSet<A extends Addr<A>>
- Returns:
- constituent ranges
-
size
Number ofAddr
es in range. -
isEmpty
default boolean isEmpty()Range is never empty.- Specified by:
isEmpty
in interfaceAddressSet<A extends Addr<A>>
- Returns:
- false
-
contains
- Specified by:
contains
in interfaceAddressSet<A extends Addr<A>>
- Parameters:
address
- candidate (cannot be null)- Returns:
- true if this sequence contains the given IP address
-
iterator
All addresses in the range. -
spliterator
Default
Spliterator.characteristics()
:Spliterator.IMMUTABLE
;Spliterator.DISTINCT
;Spliterator.ORDERED
;Spliterator.SORTED
;Spliterator.NONNULL
.Spliterator.trySplit()
is implemented.- Specified by:
spliterator
in interfaceIterable<A extends Addr<A>>
- Returns:
- instance
-
stream
All addresses in the range.- Returns:
- from first to last
-
blocks
Streams arbitrary range as valid CIDR blocks.- Returns:
- stream
-
contiguous
Tests if this range can create a contiguous range with another. That is, eitherintersects(Range)
oradjacent(Range)
are true.- Parameters:
r
- another range- Returns:
- true if contiguous
-
intersects
Tests if there is any overlap in the address ranges.- Parameters:
r
- another range- Returns:
- true on intersection
-
adjacent
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
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:
-