JAL-2226 new method to search for annotation matching particular description as well...
[jalview.git] / src / jalview / datamodel / Sequence.java
index 552349f..3bd7b4b 100755 (executable)
@@ -1799,13 +1799,32 @@ public class Sequence extends ASequence implements SequenceI
   public List<AlignmentAnnotation> getAlignmentAnnotations(String calcId,
           String label)
   {
+    return getAlignmentAnnotations(calcId, label, null, true);
+  }
+
+  @Override
+  public List<AlignmentAnnotation> getAlignmentAnnotations(String calcId,
+          String label, String description)
+  {
+    return getAlignmentAnnotations(calcId, label, description, false);
+  }
+
+  private List<AlignmentAnnotation> getAlignmentAnnotations(String calcId,
+          String label, String description, boolean nullWildcard)
+  {
     List<AlignmentAnnotation> result = new ArrayList<>();
     if (this.annotation != null)
     {
       for (AlignmentAnnotation ann : annotation)
       {
-        if (ann.calcId != null && ann.calcId.equals(calcId)
-                && ann.label != null && ann.label.equals(label))
+        if (((nullWildcard && calcId == null)
+                || (ann.calcId != null && ann.calcId.equals(calcId)))
+                && ((nullWildcard && label == null)
+                        || (ann.label != null && ann.label.equals(label)))
+                && ((nullWildcard && description == null)
+                        || (ann.description != null
+                                && ann.description.equals(description))))
+
         {
           result.add(ann);
         }