From: hansonr Date: Sun, 22 Sep 2019 16:35:42 +0000 (-0400) Subject: JAL-3253-applet JAL-3397 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=453687279dd54095ec2a92b69cb2210a3ff0d586;p=jalview.git JAL-3253-applet JAL-3397 fixing CrossRef equals broken by reversion of changes relating to equalsInterval. adds equalsWithParent --- diff --git a/src/intervalstore/nonc/IntervalStore0Impl.java b/src/intervalstore/nonc/IntervalStore0Impl.java index dd925c6..ffcb722 100644 --- a/src/intervalstore/nonc/IntervalStore0Impl.java +++ b/src/intervalstore/nonc/IntervalStore0Impl.java @@ -74,7 +74,7 @@ public class IntervalStore0Impl extends IntervalStore0 boolean sameInterval(IntervalI i1, IntervalI i2) { // avoiding equals() for JavaScript performance - return ((SequenceFeature) i1).equals((SequenceFeature) i2, false); + return ((SequenceFeature) i1).equalsWithParent((SequenceFeature) i2); } } diff --git a/src/intervalstore/nonc/IntervalStoreImpl.java b/src/intervalstore/nonc/IntervalStoreImpl.java index 7cc5f1b..8456b7f 100644 --- a/src/intervalstore/nonc/IntervalStoreImpl.java +++ b/src/intervalstore/nonc/IntervalStoreImpl.java @@ -70,7 +70,8 @@ public class IntervalStoreImpl extends IntervalStore protected boolean sameInterval(IntervalI i1, IntervalI i2) { // avoiding equals() for JavaScript performance - return ((SequenceFeature) i1).equals((SequenceFeature) i2, false); + // could be CrossRef with ignoreParent==true + return ((SequenceFeature) i1).equalsWithParent((SequenceFeature) i2); } } diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 1ab8a24..ed87f05 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -37,8 +37,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import intervalstore.api.IntervalI; - /** * Functions for cross-referencing sequence databases. * @@ -643,20 +641,20 @@ public class CrossRef // equals, because that is part of the IntervalI interface, // and IntervalStore may need that for proper, faster // processing. - // @Override - // public boolean equals(Object o) - // { - // return super.equals(o, true); - // } - // + // But SequenceFeature changes were reverted... @Override - public boolean equalsInterval(IntervalI sf) + public boolean equals(Object o) { - return sf != null - && equals((SequenceFeature) sf, true); + return o instanceof SequenceFeature + && equalsWithParent((SequenceFeature) o); } - }; + @Override + public boolean equalsWithParent(SequenceFeature sf) + { + return sf != null && equals(sf, true); + } + }; matched.addSequenceFeature(newFeature); } } diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index bf0b996..1af23a4 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -217,8 +217,20 @@ public class SequenceFeature implements FeatureLocationI @Override public boolean equals(Object o) { - return (o != null && (o instanceof SequenceFeature) - && equals(((SequenceFeature) o), false)); + return (o instanceof SequenceFeature + && equalsWithParent((SequenceFeature) o)); + } + + /** + * BH 2019.09.22 required due to subclassing by CrossRef and used by + * intervalstore.nonc.IntervalStoreImpl + * + * @param sf + * @return + */ + public boolean equalsWithParent(SequenceFeature sf) + { + return equals(sf, false); } /**