package jalview.util.matcher;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
}
@Override
- public Iterator<KeyedMatcherI> getMatchers()
+ public Iterable<KeyedMatcherI> getMatchers()
{
- return matchConditions.iterator();
+ return matchConditions;
}
@Override
package jalview.util.matcher;
-import java.util.Iterator;
import java.util.function.Function;
/**
*
* @return
*/
- Iterator<KeyedMatcherI> getMatchers();
+ Iterable<KeyedMatcherI> getMatchers();
/**
* Answers true if this object contains no conditions
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
+import java.util.Iterator;
import java.util.function.Function;
import org.testng.annotations.Test;
kms.and(km);
assertFalse(kms.isEmpty());
}
+
+ @Test
+ public void testGetMatchers()
+ {
+ KeyedMatcherSetI kms = new KeyedMatcherSet();
+
+ /*
+ * empty iterable:
+ */
+ Iterator<KeyedMatcherI> iterator = kms.getMatchers().iterator();
+ assertFalse(iterator.hasNext());
+
+ /*
+ * one matcher:
+ */
+ KeyedMatcherI km1 = new KeyedMatcher("AF", Condition.GE, -2F);
+ kms.and(km1);
+ iterator = kms.getMatchers().iterator();
+ assertSame(km1, iterator.next());
+ assertFalse(iterator.hasNext());
+
+ /*
+ * two matchers:
+ */
+ KeyedMatcherI km2 = new KeyedMatcher("AF", Condition.LT, 8F);
+ kms.and(km2);
+ iterator = kms.getMatchers().iterator();
+ assertSame(km1, iterator.next());
+ assertSame(km2, iterator.next());
+ assertFalse(iterator.hasNext());
+ }
}