JAL-2446 FeatureStore.isEmpty() added
[jalview.git] / src / jalview / datamodel / features / FeatureStore.java
index cb4bd6f..4e70dda 100644 (file)
@@ -23,6 +23,7 @@ public class FeatureStore
 
   /*
    * Non-positional features have no (zero) start/end position.
+   * Kept as a separate list in case this criterion changes in future.
    */
   List<SequenceFeature> nonPositionalFeatures;
 
@@ -609,4 +610,21 @@ public class FeatureStore
 
     return removed;
   }
+
+  /**
+   * Answers true if this store has no features, else false
+   * 
+   * @return
+   */
+  public boolean isEmpty()
+  {
+    boolean hasFeatures = !nonNestedFeatures.isEmpty()
+            || (contactFeatureStarts != null && !contactFeatureStarts
+                    .isEmpty())
+            || (nonPositionalFeatures != null && !nonPositionalFeatures
+                    .isEmpty())
+            || (nestedFeatures != null && nestedFeatures.size() > 0);
+
+    return !hasFeatures;
+  }
 }