}
}
- /* (non-Javadoc)
- * @see jalview.datamodel.SearchResultsI#addResult(jalview.datamodel.SequenceI, int, int)
- */
@Override
public SearchResultMatchI addResult(SequenceI seq, int start, int end)
{
Match m = new Match(seq, start, end);
- matches.add(m);
+ if (!matches.contains(m))
+ {
+ matches.add(m);
+ }
return m;
}
- /* (non-Javadoc)
- * @see jalview.datamodel.SearchResultsI#involvesSequence(jalview.datamodel.SequenceI)
- */
@Override
public boolean involvesSequence(SequenceI sequence)
{
return false;
}
- /* (non-Javadoc)
- * @see jalview.datamodel.SearchResultsI#getResults(jalview.datamodel.SequenceI, int, int)
- */
@Override
public int[] getResults(SequenceI sequence, int start, int end)
{
return count;
}
- /* (non-Javadoc)
- * @see jalview.datamodel.SearchResultsI#getSize()
- */
@Override
public int getSize()
{
return matches.size();
}
- /* (non-Javadoc)
- * @see jalview.datamodel.SearchResultsI#isEmpty()
- */
@Override
public boolean isEmpty()
{
return matches.isEmpty();
}
- /* (non-Javadoc)
- * @see jalview.datamodel.SearchResultsI#getResults()
- */
@Override
public List<SearchResultMatchI> getResults()
{
{
/**
- * Adds one region to the results
+ * Adds one region to the results (unless already added, to avoid duplicates)
*
* @param seq
- * Sequence
* @param start
- * int
* @param end
- * int
* @return
*/
SearchResultMatchI addResult(SequenceI seq, int start, int end);
"Didn't set expected number of columns in total for two successive marks",
2, tbs.cardinality());
}
+
+ /**
+ * Test to verify adding doesn't create duplicate results
+ */
+ @Test(groups = { "Functional" })
+ public void testAddResult()
+ {
+ SequenceI seq1 = new Sequence("", "abcdefghijklm");
+ SearchResultsI sr = new SearchResults();
+ sr.addResult(seq1, 3, 5);
+ assertEquals(1, sr.getSize());
+ sr.addResult(seq1, 3, 5);
+ assertEquals(1, sr.getSize());
+ sr.addResult(seq1, 3, 6);
+ assertEquals(2, sr.getSize());
+ }
}