Package org.deepsymmetry.beatlink
Class DeviceReference
- java.lang.Object
-
- org.deepsymmetry.beatlink.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 Summary
Fields Modifier and Type Field Description InetAddress
address
The IP address at which the device can be found.int
deviceNumber
The device number reported by the device.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DeviceReference
getDeviceReference(int number, InetAddress address)
Get a unique device identifier by device number and address.static DeviceReference
getDeviceReference(DeviceAnnouncement announcement)
Get a unique device identifier corresponding to a device we have received an announcement packet from.static DeviceReference
getDeviceReference(DeviceUpdate update)
Get a unique device identifier corresponding to a device we have received an update packet from.String
toString()
-
-
-
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 deviceaddress
- 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
-
-