Package com.metratec.lib.connection
Class EthernetDevice
- java.lang.Object
-
- com.metratec.lib.connection.EthernetDevice
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<EthernetDevice>
public class EthernetDevice extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<EthernetDevice>
Class for an ethernet device- Author:
- Matthias Neumann (neumann@metratec.com)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EthernetDevice()
Constructs a new Ethernet device.EthernetDevice(java.lang.String ipAddress, java.lang.String macAddress, java.lang.String deviceName, boolean isReachable)
Constructs a new Ethernet device with the specific parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(EthernetDevice obj)
Compare this device to other device.boolean
equals(java.lang.Object obj)
Compare to another ethernet device.java.lang.String
getDeviceName()
java.lang.String
getIPAddress()
java.lang.String
getMACAddress()
boolean
isReachable()
void
setDeviceName(java.lang.String deviceName)
set the device namevoid
setIPAddress(java.lang.String ipAddress)
set the IP Addressvoid
setMACAddress(java.lang.String macAddress)
set the MAC Addressvoid
setReachable(boolean isReachable)
set the reachable flag
-
-
-
Constructor Detail
-
EthernetDevice
public EthernetDevice()
Constructs a new Ethernet device.
-
EthernetDevice
public EthernetDevice(java.lang.String ipAddress, java.lang.String macAddress, java.lang.String deviceName, boolean isReachable)
Constructs a new Ethernet device with the specific parameters.- Parameters:
ipAddress
- the IP address of the device, can read with thegetIPAddress()
method.macAddress
- the MAC address of the device, can read with thegetMACAddress()
method.deviceName
- the device name, can read with thegetDeviceName()
method.isReachable
- reachable flag, can read with theisReachable()
method.
-
-
Method Detail
-
getIPAddress
public java.lang.String getIPAddress()
- Returns:
- the IP Address
-
getMACAddress
public java.lang.String getMACAddress()
- Returns:
- MAC Address
-
getDeviceName
public java.lang.String getDeviceName()
- Returns:
- the device name
-
isReachable
public boolean isReachable()
- Returns:
- true if the Ethernet device is reachable (is in a reachable subnet), else false
-
setIPAddress
public void setIPAddress(java.lang.String ipAddress)
set the IP Address- Parameters:
ipAddress
- IP Address
-
setMACAddress
public void setMACAddress(java.lang.String macAddress)
set the MAC Address- Parameters:
macAddress
- MAC Address
-
setDeviceName
public void setDeviceName(java.lang.String deviceName)
set the device name- Parameters:
deviceName
- device name
-
setReachable
public void setReachable(boolean isReachable)
set the reachable flag- Parameters:
isReachable
- true if the Ethernet device is reachable (is in a reachable subnet), else false
-
compareTo
public int compareTo(EthernetDevice obj)
Compare this device to other device. The primary key is the device IP address and the secondary key is the MAC address, i.e. they are only considered equal if both the IP and MAC are the same. Addresses are currently compared like strings since the original design of EthernetDevice is not type-safe. IP and MAC addresses can be null.- Specified by:
compareTo
in interfacejava.lang.Comparable<EthernetDevice>
- Parameters:
obj
- Device to compare to.- Returns:
- Negative value if this device is "less than" obj, 0 if this device "equals" obj, positive value if this device is "greater than" obj.
-
equals
public boolean equals(java.lang.Object obj)
Compare to another ethernet device. They are considered equal if they have the same IP and MAC addresses. More precisely, the definition of equivalence is the same as for thecompareTo(EthernetDevice)
method.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- Ethernet device to compare.- Returns:
- True if the objects are equal, otherwise false.
-
-