IP
- The type of IP address in the subnet.public abstract class Subnet<IP extends IPAddress<IP>> extends AbstractIPRange<IP>
Modifier and Type | Method and Description |
---|---|
IP |
from()
Returns the first IP address in this range.
|
static boolean |
isSubnet(CharSequence s)
Tests whether or not a
CharSequence is a valid subnet. |
static boolean |
isSubnet(CharSequence s,
int start,
int end)
Tests whether or not a portion of a
CharSequence is a valid subnet. |
int |
prefixLength()
Returns the length of the prefix of this subnet.
|
IP |
routingPrefix()
Returns the routing prefix of this subnet.
|
IP |
to()
Returns the last IP address in this range.
|
String |
toString() |
static Optional<Subnet<?>> |
tryValueOf(CharSequence cidrNotation)
Attempts to return a subnet represented by a
CharSequence . |
static Optional<Subnet<?>> |
tryValueOf(CharSequence cidrNotation,
int start,
int end)
Attempts to return a subnet represented by a portion of a
CharSequence . |
static Subnet<?> |
valueOf(CharSequence cidrNotation)
Returns a subnet represented by a CIDR notation.
|
static Subnet<?> |
valueOf(CharSequence routingPrefix,
int prefixLength)
Returns a subnet represented by a routing prefix and a prefix length.
|
static Subnet<?> |
valueOf(CharSequence cidrNotation,
int start,
int end)
Returns a subnet represented by a CIDR notation.
|
static Subnet<?> |
valueOf(IPAddress<?> routingPrefix,
int prefixLength)
Returns a subnet represented by a routing prefix and a prefix length.
|
equals, hashCode
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, clear, contains, contains, containsAll, forEach, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, toArray, toArray
parallelStream, spliterator, stream
public final IP from()
IPRange
public final IP to()
IPRange
IPRange.from()
if the IP range contains only one IP address.public final IP routingPrefix()
public final int prefixLength()
public static Subnet<?> valueOf(CharSequence cidrNotation)
cidrNotation
- The CIDR notation representing the subnet.NullPointerException
- If the given CIDR notation is null
.IllegalArgumentException
- If the given CIDR notation is invalid.public static Subnet<?> valueOf(CharSequence cidrNotation, int start, int end)
cidrNotation
- The CIDR notation representing the 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<Subnet<?>> tryValueOf(CharSequence cidrNotation)
CharSequence
.cidrNotation
- The possible CIDR notation representing the subnet.Optional
with the subnet represented by the given CIDR notation, or Optional.empty()
if the given CIDR notation is
null
or invalid.public static Optional<Subnet<?>> tryValueOf(CharSequence cidrNotation, int start, int end)
CharSequence
.cidrNotation
- The possible CIDR notation representing the 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 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 Subnet<?> valueOf(IPAddress<?> 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 subnet.prefixLength
- The length of the prefix of the 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 subnet of the given prefix length that contains
the routing prefix.public static Subnet<?> 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 subnet.prefixLength
- The length of the prefix of the 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 subnet of the given prefix length that contains
the routing prefix.valueOf(IPAddress, int)
public static boolean isSubnet(CharSequence s)
CharSequence
is a valid subnet.s
- The CharSequence
to test.true
if the CharSequence
is a valid subnet, or false
otherwise.public static boolean isSubnet(CharSequence s, int start, int end)
CharSequence
is a valid 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 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.