From: Jim Procter Date: Thu, 16 Jun 2016 12:47:05 +0000 (+0100) Subject: JAL-2110 equals and hashcode should check fromSeq X-Git-Tag: Release_2_10_0~140^2~5^2~49^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5cc7268518b8689fe212c481ea962a8afacc6d61;p=jalview.git JAL-2110 equals and hashcode should check fromSeq --- diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index 473a534..a4b99bf 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -60,14 +60,15 @@ public class AlignedCodonFrame } /** - * Returns a hashCode derived from the hashcodes of the mappings + * Returns a hashCode derived from the hashcodes of the mappings and fromSeq * * @see SequenceToSequenceMapping#hashCode() */ @Override public int hashCode() { - return mapping.hashCode(); + return (fromSeq == null ? 0 : fromSeq.hashCode() * 31) + + mapping.hashCode(); } /** @@ -88,7 +89,12 @@ public class AlignedCodonFrame { return that.mapping == null; } - return this.mapping.equals(that.mapping); + // TODO: can simplify by asserting fromSeq is a dataset sequence + return (this.fromSeq == that.fromSeq || (this.fromSeq != null + && that.fromSeq != null + && this.fromSeq.getDatasetSequence() != null && this.fromSeq + .getDatasetSequence() == that.fromSeq + .getDatasetSequence())) && this.mapping.equals(that.mapping); } public SequenceI getFromSeq()