X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureCommand.java;h=0a7000b8167687eb1b18c7d6c73329a688f91bb3;hb=600851b134c738f1453881fa60a7b699377b8e52;hp=f7875ab764cab5e9730b1737bead90acf4306155;hpb=bee310c7b5755403cedfb7f717f65769bb4b59d5;p=jalview.git diff --git a/src/jalview/structure/StructureCommand.java b/src/jalview/structure/StructureCommand.java index f7875ab..0a7000b 100644 --- a/src/jalview/structure/StructureCommand.java +++ b/src/jalview/structure/StructureCommand.java @@ -72,4 +72,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; + } + }