IP - The type of IP address in the range.public interface IPRange<IP extends IPAddress<IP>> extends Collection<IP>
 IP ranges are immutable collections of IP addresses. Any attempt to modify them will must result in an UnsupportedOperationException.
 
 Warning: IP ranges can be very large; IPv4 ranges can contain up to 232 IP addresses, and IPv6 ranges can contain up to
 2128 IP addresses. Iterating over such large IP ranges can take a long time, and calling toArray() or
 toArray(Object[]) can cause OutOfMemoryErrors.
| Modifier and Type | Method and Description | 
|---|---|
default boolean | 
add(IP ipAddress)
Throws an  
UnsupportedOperationException. | 
default boolean | 
addAll(Collection<? extends IP> c)
Throws an  
UnsupportedOperationException. | 
default void | 
clear()
Throws an  
UnsupportedOperationException. | 
default boolean | 
contains(IP ipAddress)
Returns whether or not an IP address is in this IP range. 
 | 
default boolean | 
contains(Object o)
Returns whether or not an object is contained in this IP range. 
 | 
default boolean | 
containsAll(Collection<?> c) | 
boolean | 
equals(Object o)
Compares the specified object with this IP range for equality. 
 | 
default void | 
forEach(Consumer<? super IP> action) | 
IP | 
from()
Returns the first IP address in this range. 
 | 
int | 
hashCode()
Returns the hash code value for this IP range. 
 | 
default boolean | 
isEmpty()
Returns whether or not this IP range is empty. 
 | 
default Iterator<IP> | 
iterator()
Returns an iterator over the IP addresses in this IP range. 
 | 
default boolean | 
remove(Object o)
Throws an  
UnsupportedOperationException. | 
default boolean | 
removeAll(Collection<?> c)
Throws an  
UnsupportedOperationException. | 
default boolean | 
removeIf(Predicate<? super IP> filter)
Throws an  
UnsupportedOperationException. | 
default boolean | 
retainAll(Collection<?> c)
Throws an  
UnsupportedOperationException. | 
int | 
size()
Returns the number of IP addresses in this IP range. 
 | 
IP | 
to()
Returns the last IP address in this range. 
 | 
default Object[] | 
toArray() | 
default <T> T[] | 
toArray(T[] a) | 
parallelStream, spliterator, streamIP from()
IP to()
from() if the IP range contains only one IP address.int size()
size in interface Collection<IP extends IPAddress<IP>>default boolean isEmpty()
false.isEmpty in interface Collection<IP extends IPAddress<IP>>default boolean contains(Object o)
contains(IPAddress) for compatible objects, or false otherwise
 (including null).
 
 This implementation checks if the given element is an instance of the class of from();
 if so, it delegates to contains(IPAddress).
contains in interface Collection<IP extends IPAddress<IP>>default boolean contains(IP ipAddress)
 This implementation returns true only if the given IP address is not null, is not smaller than from() and not larger
 than to().
ipAddress - The IP address to check.true if the given IP address is in this IP range, or false otherwise.Comparable.compareTo(Object)default Iterator<IP> iterator()
 The returned iterator must throw an UnsupportedOperationException when its Iterator.remove() method is called.
 
 This implementation returns an iterator that starts at from() and iterates up to and including to().
default Object[] toArray()
 This implementation return an array containing all IP addresses returned by iterating from from() to to() inclusive.
toArray in interface Collection<IP extends IPAddress<IP>>default <T> T[] toArray(T[] a)
 This implementation return an array containing all IP addresses returned by iterating from from() to to() inclusive.
 If the given array is not large enough to contain all IP addresses a new array is created with a length equal to the number of IP addresses.
toArray in interface Collection<IP extends IPAddress<IP>>default boolean add(IP ipAddress)
UnsupportedOperationException.add in interface Collection<IP extends IPAddress<IP>>default boolean remove(Object o)
UnsupportedOperationException.remove in interface Collection<IP extends IPAddress<IP>>default boolean containsAll(Collection<?> c)
 If the given collection collection is another IP range, this implementation checks if this contains(Object) returns true
 for both ipRange.from() and ipRange.to(), where ipRange is the given collection cast to IPRange.
 Because IP ranges contain consecutive IP ranges, this IP range then automatically contains the entire IP range.
 
 Otherwise, this implementation iterates over the given collection, checking for each element if it is contained in this IP range according to
 contains(Object).
containsAll in interface Collection<IP extends IPAddress<IP>>default boolean addAll(Collection<? extends IP> c)
UnsupportedOperationException.addAll in interface Collection<IP extends IPAddress<IP>>default boolean removeAll(Collection<?> c)
UnsupportedOperationException.removeAll in interface Collection<IP extends IPAddress<IP>>default boolean removeIf(Predicate<? super IP> filter)
UnsupportedOperationException.removeIf in interface Collection<IP extends IPAddress<IP>>default boolean retainAll(Collection<?> c)
UnsupportedOperationException.retainAll in interface Collection<IP extends IPAddress<IP>>default void clear()
UnsupportedOperationException.clear in interface Collection<IP extends IPAddress<IP>>boolean equals(Object o)
true if and only if the specified object is also an IP range,
 and both IP ranges have the same from and to addresses.
 This implies that both IP ranges contain the same IP addresses.
 
 More formally, two IP ranges range1 and range2 are equal if
 
 range1.from().equals(range2.from()) && range1.to().equals(range2.to())int hashCode()
 from().hashCode() * 31 + to().hashCode()
 This ensures that range1.equals(range2) implies that range1.hashCode() == range2.hashCode() for any two IP ranges
 range1 and range2, as required by the general contract of Object.hashCode().Copyright © 2019–2023. All rights reserved.