public final class IPv4Subnet extends Subnet<IPv4Address> implements IPv4Range
Modifier and Type | Method and Description |
---|---|
static boolean |
isIPv4Subnet(CharSequence s)
Tests whether or not a
CharSequence is a valid IPv4 subnet. |
static boolean |
isIPv4Subnet(CharSequence s,
int start,
int end)
Tests whether or not a portion of a
CharSequence is a valid IPv4 subnet. |
int |
size()
Returns the number of IP addresses in this IP range.
|
Spliterator<IPv4Address> |
spliterator() |
static Optional<IPv4Subnet> |
tryValueOfIPv4(CharSequence cidrNotation)
Attempts to return an IPv4 subnet represented by a
CharSequence . |
static Optional<IPv4Subnet> |
tryValueOfIPv4(CharSequence cidrNotation,
int start,
int end)
Attempts to return an IPv4 subnet represented by a portion of a
CharSequence . |
static IPv4Subnet |
valueOf(CharSequence cidrNotation)
Returns an IPv4 subnet represented by a CIDR notation.
|
static IPv4Subnet |
valueOf(CharSequence routingPrefix,
CharSequence netmask)
Returns an IPv4 subnet represented by a routing prefix and a netmask.
|
static IPv4Subnet |
valueOf(CharSequence routingPrefix,
int prefixLength)
Returns an IPv4 subnet represented by a routing prefix and a prefix length.
|
static IPv4Subnet |
valueOf(CharSequence cidrNotation,
int start,
int end)
Returns an IPv4 subnet represented by a CIDR notation.
|
static IPv4Subnet |
valueOf(IPv4Address routingPrefix,
int prefixLength)
Returns an IPv4 subnet represented by a routing prefix and a prefix length.
|
static IPv4Subnet |
valueOf(IPv4Address routingPrefix,
IPv4Address netmask)
Returns an IPv4 subnet represented by a routing prefix and a netmask.
|
from, isSubnet, isSubnet, prefixLength, routingPrefix, to, toString, tryValueOf, tryValueOf, valueOf
equals, hashCode
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, clear, contains, contains, containsAll, equals, forEach, from, hashCode, isEmpty, iterator, remove, removeAll, removeIf, retainAll, to, toArray, toArray
parallelStream, stream
public int size()
IPRange
size
in interface IPRange<IPv4Address>
size
in interface Collection<IPv4Address>
public Spliterator<IPv4Address> spliterator()
spliterator
in interface Iterable<IPv4Address>
spliterator
in interface Collection<IPv4Address>
public static IPv4Subnet valueOf(CharSequence cidrNotation)
cidrNotation
- The CIDR notation representing the IPv4 subnet.NullPointerException
- If the given CIDR notation is null
.IllegalArgumentException
- If the given CIDR notation is invalid.public static IPv4Subnet valueOf(CharSequence cidrNotation, int start, int end)
cidrNotation
- The CIDR notation representing the IPv4 subnet.start
- The index in the CharSequence
where the CIDR notation starts, inclusive.end
- The index in the CharSequence
where the CIDR notation ends, exclusive.NullPointerException
- If the given CIDR notation is null
.IndexOutOfBoundsException
- If the start index is negative, or if the end index is larger than the length of the CharSequence
,
or if the start index is larger than the end index.IllegalArgumentException
- If the given CIDR notation is invalid.public static Optional<IPv4Subnet> tryValueOfIPv4(CharSequence cidrNotation)
CharSequence
.cidrNotation
- The possible CIDR notation representing the IPv4 subnet.Optional
with the IPv4 subnet represented by the given CIDR notation,
or Optional.empty()
if the given CIDR notation is null
or invalid.public static Optional<IPv4Subnet> tryValueOfIPv4(CharSequence cidrNotation, int start, int end)
CharSequence
.cidrNotation
- The possible CIDR notation representing the IPv4 subnet.start
- The index in the CharSequence
where the CIDR notation starts, inclusive.end
- The index in the CharSequence
where the CIDR notation ends, exclusive.Optional
with the IPv4 subnet represented by the given CIDR notation,
or Optional.empty()
if the given CIDR notation is null
or invalid.IndexOutOfBoundsException
- If the start index is negative, or if the end index is larger than the length of the CharSequence
,
or if the start index is larger than the end index (unless if the CharSequence
is null
).public static IPv4Subnet valueOf(IPv4Address routingPrefix, int prefixLength)
192.168.0.0
is valid for prefix length 16
, but 192.168.0.1
is not.routingPrefix
- The routing prefix of the IPv4 subnet.prefixLength
- The length of the prefix of the IPv4 subnet.NullPointerException
- If the given routing prefix is null
.IllegalArgumentException
- If the given prefix length is not valid for the IP address,
or if the given routing prefix is not the start of the IPv4 subnet of the given prefix length that
contains the routing prefix.public static IPv4Subnet valueOf(CharSequence routingPrefix, int prefixLength)
192.168.0.0
is valid for prefix length 16
, but 192.168.0.1
is not.routingPrefix
- The routing prefix of the IPv4 subnet.prefixLength
- The length of the prefix of the IPv4 subnet.NullPointerException
- If the given routing prefix is null
.IllegalArgumentException
- If the given routing prefix does not represent a valid IP address,
or if the given prefix length is not valid for the IP address,
or if the given routing prefix is not the start of the IPv4 subnet of the given prefix length that
contains the routing prefix.valueOf(IPv4Address, int)
public static IPv4Subnet valueOf(IPv4Address routingPrefix, IPv4Address netmask)
192.168.0.0
is valid for prefix length 16
, but 192.168.0.1
is not.routingPrefix
- The routing prefix of the IPv4 subnet.netmask
- The netmask of the IPv4 subnet.NullPointerException
- If the given routing prefix or netmask is null
.IllegalArgumentException
- If the given routing prefix or netmask does not represent a valid IP address,
or if the given netmask is not a valid netmask,
or if the given routing prefix is not the start of the IPv4 subnet of the given prefix length that
contains the routing prefix.IPv4Address.isValidNetmask()
public static IPv4Subnet valueOf(CharSequence routingPrefix, CharSequence netmask)
192.168.0.0
is valid for prefix length 16
, but 192.168.0.1
is not.routingPrefix
- The routing prefix of the IPv4 subnet.netmask
- The netmask of the IPv4 subnet.NullPointerException
- If the given routing prefix or netmask is null
.IllegalArgumentException
- If the given routing prefix or netmask does not represent a valid IP address,
or if the given netmask is not a valid netmask,
or if the given routing prefix is not the start of the IPv4 subnet of the given prefix length that
contains the routing prefix.valueOf(IPv4Address, int)
,
IPv4Address.isValidNetmask()
public static boolean isIPv4Subnet(CharSequence s)
CharSequence
is a valid IPv4 subnet.s
- The CharSequence
to test.true
if the CharSequence
is a valid IPv4 subnet, or false
otherwise.public static boolean isIPv4Subnet(CharSequence s, int start, int end)
CharSequence
is a valid IPv4 subnet.s
- The CharSequence
to test.start
- The index in the CharSequence
to start checking at, inclusive.end
- The index in the CharSequence
to end checking at, exclusive.true
if the CharSequence
is a valid IPv4 subnet, or false
otherwise.IndexOutOfBoundsException
- If the start index is negative, or if the end index is larger than the length of the CharSequence
,
or if the start index is larger than the end index (unless if the CharSequence
is null
).Copyright © 2019–2023. All rights reserved.