Class DeviceReference


  • public class DeviceReference
    extends Object
    Uniquely identifies a device on the network. We used to use just the IP address for this, but the introduction of the XDJ-XZ completely broke that, because it reports two CDJs and a mixer all on the same IP address. This immutable class combines the device number and IP address as a joint key. The factory method ensures that for a given device number and address pair, the same instance will always be returned, so object reference equality can be used to distinguish devices in sets and hash maps.
    Since:
    0.6.0
    Author:
    James Elliott
    • Field Detail

      • deviceNumber

        public final int deviceNumber
        The device number reported by the device.
      • address

        public final InetAddress address
        The IP address at which the device can be found.
    • Method Detail

      • getDeviceReference

        public static DeviceReference getDeviceReference​(int number,
                                                         InetAddress address)
        Get a unique device identifier by device number and address.
        Parameters:
        number - the device number reported by the device
        address - the IP address at which the device can be found
        Returns:
        the reference uniquely identifying the device with that number and address
      • getDeviceReference

        public static DeviceReference getDeviceReference​(DeviceAnnouncement announcement)
        Get a unique device identifier corresponding to a device we have received an announcement packet from.
        Parameters:
        announcement - the device announcement received
        Returns:
        the reference uniquely identifying the device which sent the announcement
      • getDeviceReference

        public static DeviceReference getDeviceReference​(DeviceUpdate update)
        Get a unique device identifier corresponding to a device we have received an update packet from.
        Parameters:
        update - the device update received
        Returns:
        the reference uniquely identifying the device which sent the update