Package io.openems.edge.core.host
Class Inet4AddressWithSubnetmask
java.lang.Object
io.openems.edge.core.host.Inet4AddressWithSubnetmask
Helper class for wrapping an IPv4 address together with its subnetmask in
CIDR format.
-
Constructor Summary
ConstructorDescriptionInet4AddressWithSubnetmask
(String label, Inet4Address inet4Address, int subnetmask) -
Method Summary
Modifier and TypeMethodDescriptionboolean
static Inet4AddressWithSubnetmask
fromString
(String value) Parse a string in the form "192.168.100.100/24" to an IPv4 address.static Inet4AddressWithSubnetmask
fromString
(String label, String value) Parse a string in the form "192.168.100.100/24" to an IPv4 address.static int
getCidrFromSubnetmask
(Inet4Address subnetmask) Converts the Subnetmask to a CIDR number.getLabel()
int
Gets the Subnetmask in CIDR format, e.g.final String
Gets the Subnetmask in string format, e.g.int
hashCode()
boolean
Determines if this address and the given address are in the same network.toString()
-
Constructor Details
-
Inet4AddressWithSubnetmask
-
-
Method Details
-
fromString
Parse a string in the form "192.168.100.100/24" to an IPv4 address. Label is set to an empty string with this factory method.- Parameters:
value
- the string in the form "192.168.100.100/24"- Returns:
- the new
Inet4AddressWithSubnetmask
- Throws:
OpenemsException
- on error
-
fromString
public static Inet4AddressWithSubnetmask fromString(String label, String value) throws OpenemsException Parse a string in the form "192.168.100.100/24" to an IPv4 address.- Parameters:
label
- a label stringvalue
- the string in the form "192.168.100.100/24"- Returns:
- the new
Inet4AddressWithSubnetmask
- Throws:
OpenemsException
- on error
-
getCidrFromSubnetmask
Converts the Subnetmask to a CIDR number.e. g. Converts "255.255.255.0" to "24".
- Parameters:
subnetmask
- the subnetmask.- Returns:
- the CIDR number.
- Throws:
OpenemsException
-
getLabel
-
getInet4Address
-
getSubnetmaskAsCidr
public int getSubnetmaskAsCidr()Gets the Subnetmask in CIDR format, e.g. "24" for "255.255.255.0".- Returns:
- the subnetmask
-
getSubnetmaskAsString
Gets the Subnetmask in string format, e.g. "255.255.255.0" for "24".- Returns:
- the subnetmask
-
toString
-
isInSameNetwork
Determines if this address and the given address are in the same network.- Parameters:
other
- the otherInet4AddressWithSubnetmask
- Returns:
- true if they are in the same network
-
hashCode
public int hashCode() -
equals
-