Class EthernetDevice

    • Constructor Detail

      • EthernetDevice

        public EthernetDevice()
        Constructs a new Ethernet device.
      • EthernetDevice

        public EthernetDevice​(String ipAddress,
                              String macAddress,
                              String deviceName,
                              boolean isReachable)
        Constructs a new Ethernet device with the specific parameters.
        Parameters:
        ipAddress - the IP address of the device, can read with the getIPAddress() method.
        macAddress - the MAC address of the device, can read with the getMACAddress() method.
        deviceName - the device name, can read with the getDeviceName() method.
        isReachable - reachable flag, can read with the isReachable() method.
    • Method Detail

      • getIPAddress

        public String getIPAddress()
        Returns:
        the IP Address
      • getMACAddress

        public String getMACAddress()
        Returns:
        MAC Address
      • getDeviceName

        public 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​(String ipAddress)
        set the IP Address
        Parameters:
        ipAddress - IP Address
      • setMACAddress

        public void setMACAddress​(String macAddress)
        set the MAC Address
        Parameters:
        macAddress - MAC Address
      • setDeviceName

        public void setDeviceName​(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 interface 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​(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 the compareTo(EthernetDevice) method.
        Overrides:
        equals in class Object
        Parameters:
        obj - Ethernet device to compare.
        Returns:
        True if the objects are equal, otherwise false.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object