immutable TMouseEvent
[nikiroo-utils.git] / src / jexer / event / TCommandEvent.java
index cdb5e2d6a70140232fa006d9fc59d0ac15588f37..fb3050b1dcc71dc2fbb99977f116f5f29dcbd616 100644 (file)
@@ -62,6 +62,30 @@ public final class TCommandEvent extends TInputEvent {
         this.cmd = cmd;
     }
 
+    /**
+     * Comparison check.  All fields must match to return true.
+     *
+     * @param rhs another TCommandEvent or TCommand instance
+     * @return true if all fields are equal
+     */
+    @Override
+    public boolean equals(final Object rhs) {
+        if (!(rhs instanceof TCommandEvent)
+            && !(rhs instanceof TCommand)
+        ) {
+            return false;
+        }
+
+        if (rhs instanceof TCommandEvent) {
+            TCommandEvent that = (TCommandEvent) rhs;
+            return (cmd.equals(that.cmd)
+                && (getTime().equals(that.getTime())));
+        }
+
+        TCommand that = (TCommand) rhs;
+        return (cmd.equals(that));
+    }
+
     /**
      * Make human-readable description of this TCommandEvent.
      *