* The list notification to copy
*/
public ListNotification(ListNotification<T> listNotification) {
- super(listNotification.getId(), new Template());
+ super(listNotification.getId(), listNotification.getCreatedTime(), listNotification.getLastUpdatedTime(), listNotification.isDismissable(), new Template());
this.key = listNotification.key;
getTemplate().add(listNotification.getTemplate());
getTemplate().getInitialContext().set(key, elements);
}
/**
- * Sets the elements to show in this notification.
+ * Sets the elements to show in this notification. This method will not call
+ * {@link #touch()}.
*
* @param elements
* The elements to show
elements.clear();
}
+ //
+ // OBJECT METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ int hashCode = super.hashCode();
+ for (T element : elements) {
+ hashCode ^= element.hashCode();
+ }
+ return hashCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ListNotification)) {
+ return false;
+ }
+ ListNotification<?> listNotification = (ListNotification<?>) object;
+ if (!super.equals(listNotification)) {
+ return false;
+ }
+ if (!key.equals(listNotification.key)) {
+ return false;
+ }
+ if (elements.size() != listNotification.elements.size()) {
+ return false;
+ }
+ for (int index = 0; index < elements.size(); ++index) {
+ if (!elements.get(index).equals(listNotification.elements.get(index))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
}