X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceFeature.java;h=1af23a4caa30791261a88784174eadd84fa56039;hb=453687279dd54095ec2a92b69cb2210a3ff0d586;hp=6f514203088bf246329d5d629b62cd0bbfeaa165;hpb=28e9024f09a78a9625ed4defa2012bf342bec51e;p=jalview.git diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index 6f51420..1af23a4 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -35,8 +35,6 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.Vector; -import intervalstore.api.IntervalI; - /** * A class that models a single contiguous feature on a sequence. If flag * 'contactFeature' is true, the start and end positions are interpreted instead @@ -219,19 +217,22 @@ public class SequenceFeature implements FeatureLocationI @Override public boolean equals(Object o) { - return (o != null && (o instanceof SequenceFeature) - && equalsInterval((SequenceFeature) o)); + return (o instanceof SequenceFeature + && equalsWithParent((SequenceFeature) o)); } /** - * Having determined that this is in fact a SequenceFeature, now check it for - * equivalence. Overridden in CrossRef; used by IntervalStore (possibly). + * BH 2019.09.22 required due to subclassing by CrossRef and used by + * intervalstore.nonc.IntervalStoreImpl + * + * @param sf + * @return */ - @Override - public boolean equalsInterval(IntervalI sf) + public boolean equalsWithParent(SequenceFeature sf) { - return equals((SequenceFeature) sf, false); + return equals(sf, false); } + /** * Overloaded method allows the equality test to optionally ignore the * 'Parent' attribute of a feature. This supports avoiding adding many @@ -244,39 +245,17 @@ public class SequenceFeature implements FeatureLocationI */ public boolean equals(SequenceFeature sf, boolean ignoreParent) { - boolean sameScore = Float.isNaN(score) ? Float.isNaN(sf.score) - : score == sf.score; - if (begin != sf.begin || end != sf.end || !sameScore) - { - return false; - } - - if (getStrand() != sf.getStrand()) - { - return false; - } - - if (!(type + description + featureGroup + getPhase()).equals( - sf.type + sf.description + sf.featureGroup + sf.getPhase())) - { - return false; - } - if (!equalAttribute(getValue("ID"), sf.getValue("ID"))) - { - return false; - } - if (!equalAttribute(getValue("Name"), sf.getValue("Name"))) - { - return false; - } - if (!ignoreParent) - { - if (!equalAttribute(getValue("Parent"), sf.getValue("Parent"))) - { - return false; - } - } - return true; + return (begin == sf.begin && end == sf.end + && getStrand() == sf.getStrand() + && (Float.isNaN(score) ? Float.isNaN(sf.score) + : score == sf.score) + && (type + description + featureGroup + getPhase()) + .equals(sf.type + sf.description + sf.featureGroup + + sf.getPhase()) + && equalAttribute(getValue("ID"), sf.getValue("ID")) + && equalAttribute(getValue("Name"), sf.getValue("Name")) + && (ignoreParent || equalAttribute(getValue("Parent"), + sf.getValue("Parent")))); } /**