X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentAnnotation.java;h=a8987461fe1de2aec290999ca651c6f24e40e02a;hb=725dd79ff4976e8e30a638a6f7dfa45eea818d57;hp=2ee45039569c5bcb6081d46f481f706ff2c10910;hpb=74f21ca6ca8fa17d53708e457d191e15904f8310;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 2ee4503..a898746 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -1647,20 +1647,27 @@ public class AlignmentAnnotation } } + /** + * Answers a (possibly empty) iterable list of those annotations in the supplied + * list whose reference sequence, calcId or label matches the supplied + * parameters. Null parameter values are ignored. + * + * @param list + * @param seq + * @param calcId + * @param label + * @return + */ public static Iterable findAnnotations( Iterable list, SequenceI seq, String calcId, String label) { - - ArrayList aa = new ArrayList<>(); + List aa = new ArrayList<>(); for (AlignmentAnnotation ann : list) { - if ((calcId == null || (ann.getCalcId() != null - && ann.getCalcId().equals(calcId))) - && (seq == null || (ann.sequenceRef != null - && ann.sequenceRef == seq)) - && (label == null - || (ann.label != null && ann.label.equals(label)))) + if ((calcId == null || calcId.equals(ann.getCalcId())) + && (seq == null || seq == ann.sequenceRef) + && (label == null || label.equals(ann.label))) { aa.add(ann); } @@ -1693,6 +1700,14 @@ public class AlignmentAnnotation return false; } + /** + * Returns a (possibly empty) iterable set of annotations in the given list + * whose calcId matches the given value (which may not be null) + * + * @param list + * @param calcId + * @return + */ public static Iterable findAnnotation( List list, String calcId) {