@Test public void testEquals() { final DefaultAlarm a = new DefaultAlarm.Builder( DeviceId.NONE, "desc", Alarm.SeverityLevel.MINOR, 3).build(); final DefaultAlarm b = new DefaultAlarm.Builder( DeviceId.NONE, "desc", Alarm.SeverityLevel.MINOR, a.timeRaised() + 1). withId(ALARM_ID).withTimeUpdated(a.timeUpdated() + 1).build(); assertEquals("id or timeRaised or timeUpdated may differ", a, b); assertNotEquals(a, new DefaultAlarm.Builder(a).withAcknowledged(!a.acknowledged()).build()); assertNotEquals(a, new DefaultAlarm.Builder(a).withManuallyClearable(!a.manuallyClearable()).build()); assertNotEquals(a, new DefaultAlarm.Builder(a).withServiceAffecting(!a.serviceAffecting()).build()); assertNotEquals(a, new DefaultAlarm.Builder(a).withAssignedUser("Changed" + a.assignedUser()).build()); }
@Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DefaultAlarm other = (DefaultAlarm) obj; if (!Objects.equals(this.deviceId, other.deviceId)) { return false; } if (!Objects.equals(this.description, other.description)) { return false; } if (!Objects.equals(this.source, other.source)) { return false; } if (!Objects.equals(this.timeCleared, other.timeCleared)) { return false; } if (this.severity != other.severity) { return false; } if (this.isServiceAffecting != other.isServiceAffecting) { return false; } if (this.isAcknowledged != other.isAcknowledged) { return false; } if (this.isManuallyClearable != other.isManuallyClearable) { return false; } if (!Objects.equals(this.assignedUser, other.assignedUser)) { return false; } return true; }
DefaultAlarm implements Alarm { @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DefaultAlarm other = (DefaultAlarm) obj; if (!Objects.equals(this.deviceId, other.deviceId)) { return false; } if (!Objects.equals(this.description, other.description)) { return false; } if (!Objects.equals(this.source, other.source)) { return false; } if (!Objects.equals(this.timeCleared, other.timeCleared)) { return false; } if (this.severity != other.severity) { return false; } if (this.isServiceAffecting != other.isServiceAffecting) { return false; } if (this.isAcknowledged != other.isAcknowledged) { return false; } if (this.isManuallyClearable != other.isManuallyClearable) { return false; } if (!Objects.equals(this.assignedUser, other.assignedUser)) { return false; } return true; } }
DefaultAlarm implements Alarm { @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DefaultAlarm other = (DefaultAlarm) obj; if (!Objects.equals(this.deviceId, other.deviceId)) { return false; } if (!Objects.equals(this.description, other.description)) { return false; } if (!Objects.equals(this.source, other.source)) { return false; } if (!Objects.equals(this.timeCleared, other.timeCleared)) { return false; } if (this.severity != other.severity) { return false; } if (this.isServiceAffecting != other.isServiceAffecting) { return false; } if (this.isAcknowledged != other.isAcknowledged) { return false; } if (this.isManuallyClearable != other.isManuallyClearable) { return false; } if (!Objects.equals(this.assignedUser, other.assignedUser)) { return false; } return true; } DefaultAlarm(); private  DefaultAlarm(final AlarmId id,
                         final DeviceId deviceId,
                         final String description,
                         final AlarmEntityId source,
                         final long timeRaised,
                         final long timeUpdated,
                         final Long timeCleared,
                         final SeverityLevel severity,
                         final boolean isServiceAffecting,
                         final boolean isAcknowledged,
                         final boolean isManuallyClearable,
                         final String assignedUser); }
DefaultAlarm implements Alarm { @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DefaultAlarm other = (DefaultAlarm) obj; if (!Objects.equals(this.deviceId, other.deviceId)) { return false; } if (!Objects.equals(this.description, other.description)) { return false; } if (!Objects.equals(this.source, other.source)) { return false; } if (!Objects.equals(this.timeCleared, other.timeCleared)) { return false; } if (this.severity != other.severity) { return false; } if (this.isServiceAffecting != other.isServiceAffecting) { return false; } if (this.isAcknowledged != other.isAcknowledged) { return false; } if (this.isManuallyClearable != other.isManuallyClearable) { return false; } if (!Objects.equals(this.assignedUser, other.assignedUser)) { return false; } return true; } DefaultAlarm(); private  DefaultAlarm(final AlarmId id,
                         final DeviceId deviceId,
                         final String description,
                         final AlarmEntityId source,
                         final long timeRaised,
                         final long timeUpdated,
                         final Long timeCleared,
                         final SeverityLevel severity,
                         final boolean isServiceAffecting,
                         final boolean isAcknowledged,
                         final boolean isManuallyClearable,
                         final String assignedUser); @Override AlarmId id(); @Override DeviceId deviceId(); @Override String description(); @Override AlarmEntityId source(); @Override long timeRaised(); @Override long timeUpdated(); @Override Long timeCleared(); @Override SeverityLevel severity(); @Override boolean serviceAffecting(); @Override boolean acknowledged(); @Override boolean manuallyClearable(); @Override String assignedUser(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); }
DefaultAlarm implements Alarm { @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DefaultAlarm other = (DefaultAlarm) obj; if (!Objects.equals(this.deviceId, other.deviceId)) { return false; } if (!Objects.equals(this.description, other.description)) { return false; } if (!Objects.equals(this.source, other.source)) { return false; } if (!Objects.equals(this.timeCleared, other.timeCleared)) { return false; } if (this.severity != other.severity) { return false; } if (this.isServiceAffecting != other.isServiceAffecting) { return false; } if (this.isAcknowledged != other.isAcknowledged) { return false; } if (this.isManuallyClearable != other.isManuallyClearable) { return false; } if (!Objects.equals(this.assignedUser, other.assignedUser)) { return false; } return true; } DefaultAlarm(); private  DefaultAlarm(final AlarmId id,
                         final DeviceId deviceId,
                         final String description,
                         final AlarmEntityId source,
                         final long timeRaised,
                         final long timeUpdated,
                         final Long timeCleared,
                         final SeverityLevel severity,
                         final boolean isServiceAffecting,
                         final boolean isAcknowledged,
                         final boolean isManuallyClearable,
                         final String assignedUser); @Override AlarmId id(); @Override DeviceId deviceId(); @Override String description(); @Override AlarmEntityId source(); @Override long timeRaised(); @Override long timeUpdated(); @Override Long timeCleared(); @Override SeverityLevel severity(); @Override boolean serviceAffecting(); @Override boolean acknowledged(); @Override boolean manuallyClearable(); @Override String assignedUser(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }