JAL-3253-applet JAL-3397
[jalview.git] / src / jalview / datamodel / SequenceFeature.java
index a71c7b1..1af23a4 100755 (executable)
@@ -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
@@ -102,16 +100,6 @@ public class SequenceFeature implements FeatureLocationI
   private String source;
 
   /**
-   * 1-based index into the featureList used by FeatureStoreJS
-   */
-  public int index1;
-
-  /**
-   * containment nesting link used by FeatureStoreJS to track starting points
-   */
-  public SequenceFeature containedBy;
-
-  /**
    * Constructs a duplicate feature. Note: Uses makes a shallow copy of the
    * otherDetails map, so the new and original SequenceFeature may reference the
    * same objects in the map.
@@ -229,7 +217,20 @@ public class SequenceFeature implements FeatureLocationI
   @Override
   public boolean equals(Object o)
   {
-    return equals(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);
   }
 
   /**
@@ -242,47 +243,19 @@ public class SequenceFeature implements FeatureLocationI
    * @param ignoreParent
    * @return
    */
-  public boolean equals(Object o, boolean ignoreParent)
+  public boolean equals(SequenceFeature sf, boolean ignoreParent)
   {
-    if (o == null || !(o instanceof SequenceFeature))
-    {
-      return false;
-    }
-
-    SequenceFeature sf = (SequenceFeature) o;
-    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"))));
   }
 
   /**
@@ -749,19 +722,7 @@ public class SequenceFeature implements FeatureLocationI
     source = theSource;
   }
 
-  @Override
-  public IntervalI getContainedBy()
-  {
-    return containedBy;
-  }
-
-  @Override
-  public void setContainedBy(IntervalI containedBy)
-  {
-    this.containedBy = (SequenceFeature) containedBy;
-
-  }
-
 }
 
 class SFSortByEnd implements Comparator<SequenceFeature>