X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureCommand.java;h=98a060ae2d82f7b7bff86dde228be4501d437528;hb=ac2ed85d81f322445555e01b67f758a77f2ede74;hp=f7875ab764cab5e9730b1737bead90acf4306155;hpb=42f4227ed213d422a87d3b22fc9e85d14ffaf53f;p=jalview.git
diff --git a/src/jalview/structure/StructureCommand.java b/src/jalview/structure/StructureCommand.java
index f7875ab..98a060a 100644
--- a/src/jalview/structure/StructureCommand.java
+++ b/src/jalview/structure/StructureCommand.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.structure;
import java.util.ArrayList;
@@ -9,6 +29,8 @@ public class StructureCommand implements StructureCommandI
private List parameters;
+ private boolean waitNeeded = false;
+
public StructureCommand(String cmd, String... params)
{
command = cmd;
@@ -21,6 +43,17 @@ public class StructureCommand implements StructureCommandI
}
}
+ public void setWaitNeeded(boolean wait)
+ {
+ waitNeeded = wait;
+ }
+
+ @Override
+ public boolean isWaitNeeded()
+ {
+ return waitNeeded;
+ }
+
@Override
public void addParameter(String param)
{
@@ -52,7 +85,7 @@ public class StructureCommand implements StructureCommandI
@Override
public String toString()
{
- if (!hasParameters())
+ if (!hasParameters())
{
return command;
}
@@ -72,4 +105,55 @@ public class StructureCommand implements StructureCommandI
return sb.toString();
}
+ @Override
+ public int hashCode()
+ {
+ int h = command.hashCode();
+ if (parameters != null)
+ {
+ for (String p : parameters)
+ {
+ h = h * 37 + p.hashCode();
+ }
+ }
+ return h;
+ }
+
+ /**
+ * Answers true if {@code obj} is a {@code StructureCommand} with the same
+ * command and parameters as this one, else false
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null || !(obj instanceof StructureCommand))
+ {
+ return false;
+ }
+ StructureCommand sc = (StructureCommand) obj;
+
+ if (!command.equals(sc.command))
+ {
+ return false;
+ }
+ if (parameters == null || sc.parameters == null)
+ {
+ return (parameters == null) && (sc.parameters == null);
+ }
+
+ int j = parameters.size();
+ if (j != sc.parameters.size())
+ {
+ return false;
+ }
+ for (int i = 0; i < j; i++)
+ {
+ if (!parameters.get(i).equals(sc.parameters.get(i)))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
}