Class ImmutableIPAddress
- java.lang.Object
-
- org.opennms.integration.api.v1.model.immutables.ImmutableIPAddress
-
- All Implemented Interfaces:
java.lang.Comparable<ImmutableIPAddress>
public class ImmutableIPAddress extends java.lang.Object implements java.lang.Comparable<ImmutableIPAddress>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.InetAddressm_inetAddress
-
Constructor Summary
Constructors Constructor Description ImmutableIPAddress(byte[] ipAddrOctets)ImmutableIPAddress(java.lang.String dottedNotation)ImmutableIPAddress(java.net.InetAddress inetAddress)ImmutableIPAddress(ImmutableIPAddress addr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ImmutableIPAddress o)ImmutableIPAddressdecr()Decrement this IP address.booleanequals(java.lang.Object obj)static intfromBytes(byte b1, byte b2, byte b3, byte b4)Returns theintvalue whose byte representation is the given 4 bytes, in big-endian order; equivalent toInts.fromByteArray(new byte[] {b1, b2, b3, b4}).inthashCode()ImmutableIPAddressincr()Increment this IP address.booleanisGreaterThan(ImmutableIPAddress other)Check if this IP address is larger than the provided IP address.booleanisGreaterThanOrEqualTo(ImmutableIPAddress other)Check if this IP address is larger or equal to the provided IP address.booleanisLessThan(ImmutableIPAddress other)Check if this IP address is smaller than the provided IP address.booleanisLessThanOrEqualTo(ImmutableIPAddress other)Check if this IP address is smaller or equal to the provided IP address.booleanisPredecessorOf(ImmutableIPAddress other)Check if this IP address is immediately before the provided IP address.booleanisSuccessorOf(ImmutableIPAddress other)Check if this IP address is immediately after the provided IP address.static ImmutableIPAddressmax(ImmutableIPAddress a, ImmutableIPAddress b)Return the larger of two IP addresses.static ImmutableIPAddressmin(ImmutableIPAddress a, ImmutableIPAddress b)java.math.BigIntegertoBigInteger()java.lang.StringtoDbString()java.net.InetAddresstoInetAddress()protected byte[]toIpAddrBytes(java.lang.String dottedNotation)protected java.lang.StringtoIpAddrString(byte[] addr)protected java.lang.StringtoIpAddrString(java.net.InetAddress addr)byte[]toOctets()java.lang.StringtoString()java.lang.StringtoUserString()
-
-
-
Constructor Detail
-
ImmutableIPAddress
public ImmutableIPAddress(ImmutableIPAddress addr)
-
ImmutableIPAddress
public ImmutableIPAddress(java.lang.String dottedNotation)
-
ImmutableIPAddress
public ImmutableIPAddress(java.net.InetAddress inetAddress)
-
ImmutableIPAddress
public ImmutableIPAddress(byte[] ipAddrOctets)
-
-
Method Detail
-
min
public static ImmutableIPAddress min(ImmutableIPAddress a, ImmutableIPAddress b)
-
toInetAddress
public java.net.InetAddress toInetAddress()
-
toOctets
public byte[] toOctets()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(ImmutableIPAddress o)
- Specified by:
compareToin interfacejava.lang.Comparable<ImmutableIPAddress>
-
toUserString
public java.lang.String toUserString()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toDbString
public java.lang.String toDbString()
-
toBigInteger
public java.math.BigInteger toBigInteger()
-
incr
public ImmutableIPAddress incr()
Increment this IP address.- Returns:
- the new IP address
- Throws:
java.lang.IllegalStateException- if it overflows
-
decr
public ImmutableIPAddress decr()
Decrement this IP address.- Returns:
- the new IP address
- Throws:
java.lang.IllegalStateException- if it underflows
-
isPredecessorOf
public boolean isPredecessorOf(ImmutableIPAddress other)
Check if this IP address is immediately before the provided IP address.- Parameters:
other- the address to check against- Returns:
- a boolean
-
isSuccessorOf
public boolean isSuccessorOf(ImmutableIPAddress other)
Check if this IP address is immediately after the provided IP address.- Parameters:
other- the address to check against- Returns:
- a boolean
-
isLessThan
public boolean isLessThan(ImmutableIPAddress other)
Check if this IP address is smaller than the provided IP address.- Parameters:
other- the address to check against- Returns:
- a boolean
-
isLessThanOrEqualTo
public boolean isLessThanOrEqualTo(ImmutableIPAddress other)
Check if this IP address is smaller or equal to the provided IP address.- Parameters:
other- the address to check against- Returns:
- a boolean
-
isGreaterThan
public boolean isGreaterThan(ImmutableIPAddress other)
Check if this IP address is larger than the provided IP address.- Parameters:
other- the address to check against- Returns:
- a boolean
-
isGreaterThanOrEqualTo
public boolean isGreaterThanOrEqualTo(ImmutableIPAddress other)
Check if this IP address is larger or equal to the provided IP address.- Parameters:
other- the address to check against- Returns:
- a boolean
-
max
public static ImmutableIPAddress max(ImmutableIPAddress a, ImmutableIPAddress b)
Return the larger of two IP addresses.
-
toIpAddrString
protected java.lang.String toIpAddrString(java.net.InetAddress addr)
-
toIpAddrString
protected java.lang.String toIpAddrString(byte[] addr)
-
toIpAddrBytes
protected byte[] toIpAddrBytes(java.lang.String dottedNotation)
-
fromBytes
public static int fromBytes(byte b1, byte b2, byte b3, byte b4)Returns theintvalue whose byte representation is the given 4 bytes, in big-endian order; equivalent toInts.fromByteArray(new byte[] {b1, b2, b3, b4}).From: Guava.
-
-