IP - The IP address subclass.public abstract class IPAddress<IP extends IPAddress<IP>> extends Object implements Comparable<IP>
 Unlike InetAddress, this class is more lightweight and contains only the IP address itself, not host names.
| Modifier and Type | Method and Description | 
|---|---|
abstract IPRange<IP> | 
asRange()
Returns an IP range containing only this IP address. 
 | 
abstract int | 
bits()
Returns the number of bits required to store the IP address. 
 | 
abstract boolean | 
equals(Object o)
Tests whether or not another object is equal to this IP address. 
 | 
abstract int | 
hashCode()
Returns a hash code value for this IP address. 
 | 
abstract boolean | 
hasNext()
Returns whether or not there is a next IP address. 
 | 
abstract boolean | 
hasPrevious()
Returns whether or not there is a previous IP address. 
 | 
static Predicate<CharSequence> | 
ifValidIPAddress(Predicate<? super IPAddress<?>> predicate)
Returns a predicate that checks whether or not  
CharSequences are valid IP addresses that match a specific predicate. | 
abstract Subnet<IP> | 
inSubnet(int prefixLength)
Returns a subnet of a specific prefix length that contains this IP address. 
 | 
static boolean | 
isIPAddress(CharSequence s)
Tests whether or not a  
CharSequence is a valid IP address. | 
static boolean | 
isIPAddress(CharSequence s,
           int start,
           int end)
Tests whether or not a portion of a  
CharSequence is a valid IP address. | 
abstract boolean | 
isLinkLocalAddress()
Returns whether or not this IP address is a link local address. 
 | 
abstract boolean | 
isLoopbackAddress()
Returns whether or not this IP address is a loopback address. 
 | 
abstract boolean | 
isMulticastAddress()
Returns whether or not this IP address is an IP multicast address. 
 | 
abstract boolean | 
isSiteLocalAddress()
Returns whether or not this IP address is a site local address. 
 | 
abstract boolean | 
isWildcardAddress()
Returns whether or not this IP address is a wildcard address. 
 | 
abstract IP | 
next()
Returns the next IP address if it exists. 
 | 
abstract IP | 
previous()
Returns the previous IP address if it exists. 
 | 
abstract IPRange<IP> | 
to(IP end)
Returns an IP range starting at this IP address and ending in another IP address. 
 | 
abstract byte[] | 
toByteArray()
Returns a byte array representation of this IP address. 
 | 
InetAddress | 
toInetAddress()
Returns this IP address as an  
InetAddress. | 
String | 
toString()
Returns a string representation of this IP address. 
 | 
static Optional<IPAddress<?>> | 
tryValueOf(CharSequence address)
Attempts to return an IP address represented by a  
CharSequence. | 
static Optional<IPAddress<?>> | 
tryValueOf(CharSequence address,
          int start,
          int end)
Attempts to return an IP address represented by a portion of a  
CharSequence. | 
static IPAddress<?> | 
valueOf(byte[] address)
Returns an IP address from a byte array representation of the address. 
 | 
static IPAddress<?> | 
valueOf(CharSequence address)
Returns an IP address represented by a  
CharSequence. | 
static IPAddress<?> | 
valueOf(CharSequence address,
       int start,
       int end)
Returns an IP address represented by a portion of a  
CharSequence. | 
static IPAddress<?> | 
valueOf(InetAddress address)
Returns an IP address represented by a  
InetAddress. | 
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompareTopublic abstract int bits()
public abstract byte[] toByteArray()
bits() divided by Byte.SIZE.
 Furthermore, the result is in network byte order; the highest order byte is in the first element.public InetAddress toInetAddress()
InetAddress.InetAddress.public abstract boolean equals(Object o)
toByteArray().
 
 Implementations do not necessary need to use toByteArray(), as long as equal IP addresses also have equal byte array representations.
public abstract int hashCode()
 Implementations do not necessarily need to use toByteArray(), as long as the general contract as specified by
 Object.hashCode() is not violated.
public String toString()
IPAddressFormatter.parse(CharSequence), the resulting IP address should be equal to this
 IP address.public abstract boolean isMulticastAddress()
true if this IP address is an IP multicast address, or false otherwise.InetAddress.isMulticastAddress()public abstract boolean isWildcardAddress()
true if this IP address is a wildcard address, or false otherwise.InetAddress.isAnyLocalAddress()public abstract boolean isLoopbackAddress()
true if this IP address is a loopback address, or false otherwise.InetAddress.isLoopbackAddress()public abstract boolean isLinkLocalAddress()
true if this IP address is a link local address, or false otherwise.InetAddress.isLinkLocalAddress()public abstract boolean isSiteLocalAddress()
true if this IP address is a site local address, or false otherwise.InetAddress.isSiteLocalAddress()public abstract boolean hasNext()
true if there is a next IP address, or false otherwise.public abstract IP next()
NoSuchElementException - If there is no next IP address.hasNext()public abstract boolean hasPrevious()
true if there is a previous IP address, or false otherwise.public abstract IP previous()
NoSuchElementException - If there is no previous IP address.hasPrevious()public abstract IPRange<IP> to(IP end)
end - The end of the IP range, inclusive.NullPointerException - If the given IP address is null.IllegalArgumentException - If the given IP address is smaller than this IP address.public abstract IPRange<IP> asRange()
public abstract Subnet<IP> inSubnet(int prefixLength)
prefixLength - The prefix length of the subnet to return.IllegalArgumentException - If the prefix length is negative or larger than bits().public static IPAddress<?> valueOf(byte[] address)
address - The array to return an IP address for.NullPointerException - If the given array is null.IllegalArgumentException - If the length of the given array is not 4 or 16.public static IPAddress<?> valueOf(CharSequence address)
CharSequence.address - The IP address as a CharSequence.NullPointerException - If the given CharSequence is null.IllegalArgumentException - If the given CharSequence does not represent a valid IP address.public static IPAddress<?> valueOf(CharSequence address, int start, int end)
CharSequence.address - The IP address as a CharSequence.start - The index in the CharSequence where the IP address starts, inclusive.end - The index in the CharSequence where the IP address ends, exclusive.NullPointerException - If the given CharSequence 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 CharSequence does not represent a valid IP address.public static Optional<IPAddress<?>> tryValueOf(CharSequence address)
CharSequence.address - The possible IP address as a CharSequence.Optional with the IP address that represents the given address, or Optional.empty() if the given
         CharSequence is nullor does not represent a valid IP address.public static Optional<IPAddress<?>> tryValueOf(CharSequence address, int start, int end)
CharSequence.address - The possible IP address as a CharSequence.start - The index in the CharSequence where the IP address starts, inclusive.end - The index in the CharSequence where the IP address ends, exclusive.Optional with the IP address that represents the given address, or Optional.empty() if the given
         CharSequence is nullor does not represent a valid IP address.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 IPAddress<?> valueOf(InetAddress address)
InetAddress.address - The IP address as a InetAddress.NullPointerException - If the given InetAddress is null.IllegalArgumentException - If the given InetAddress is not supported.public static boolean isIPAddress(CharSequence s)
CharSequence is a valid IP address.s - The CharSequence to test.true if the CharSequence is a valid IP address, or false otherwise.public static boolean isIPAddress(CharSequence s, int start, int end)
CharSequence is a valid IP address.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 IP address, 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).public static Predicate<CharSequence> ifValidIPAddress(Predicate<? super IPAddress<?>> predicate)
CharSequences are valid IP addresses that match a specific predicate.
 This predicate can handle null values, which do not match the predicate.predicate - The predicate to check if CharSequences are valid IP addresses.CharSequences are valid IP addresses that match the given predicate.isIPAddress(CharSequence)Copyright © 2019–2023. All rights reserved.