DeviceID { @Override public boolean equals(Object o) { if(o == null) return false; if(!o.getClass().equals(this.getClass())) return false; DeviceID id = (DeviceID)o; return this.deviceID == id.deviceID; } private  DeviceID(long deviceIDAs32BitValue); static DeviceID fromString(String deviceID); static DeviceID fromStringWithBaseID(String offset, DeviceID baseID); static DeviceID fromByteArray(byte[] deviceIDBytes); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); byte[] asByteArray(); DeviceID resolve(DeviceID baseID); static final DeviceID ENOCEAN_BROADCAST_ID; static final int ENOCEAN_ESP_ID_LENGTH; }
@Test public void testEquals() throws InvalidDeviceIDException { DeviceID id1 = DeviceID.fromString("0x00000000"); DeviceID id2 = DeviceID.fromString("0x00000000"); DeviceID id3 = DeviceID.fromString("0xFFFFFFFF"); DeviceID id4 = DeviceID.fromString("0xFFFFFFFF"); Assert.assertTrue("Expecting ID1 to equals ID2", id1.equals(id2)); Assert.assertTrue("Expecting ID2 to equals ID1", id2.equals(id1)); Assert.assertFalse("Expecting ID1 NOT to equals ID3", id1.equals(id3)); Assert.assertFalse("Expecting ID3 NOT to equals ID1", id3.equals(id1)); Assert.assertTrue("Expecting ID3 to equals ID4", id3.equals(id4)); Assert.assertTrue("Expecting ID4 to equals ID3", id4.equals(id3)); Assert.assertFalse(id1.equals(null)); Assert.assertFalse(id1.equals(new Object())); }