@Test public void combineTest() { LookupResultItem item1 = new LookupResultItem("p1", "proj1", 2); LookupResultItem item2 = new LookupResultItem("p1", "proj2", 4); item1.combine(item2); assertEquals("p1", item1.getPhrase()); assertEquals(6, item1.getScore()); assertThat(item1.getProjects(), containsInAnyOrder("proj1", "proj2")); }
void combine(final LookupResultItem other) { if (other == null || !canBeCombinedWith(other)) { throw new IllegalArgumentException("Cannot combine with " + other); } projects.addAll(other.projects); score += other.score; }
LookupResultItem implements Comparable<LookupResultItem> { void combine(final LookupResultItem other) { if (other == null || !canBeCombinedWith(other)) { throw new IllegalArgumentException("Cannot combine with " + other); } projects.addAll(other.projects); score += other.score; } }
LookupResultItem implements Comparable<LookupResultItem> { void combine(final LookupResultItem other) { if (other == null || !canBeCombinedWith(other)) { throw new IllegalArgumentException("Cannot combine with " + other); } projects.addAll(other.projects); score += other.score; } LookupResultItem(final String phrase, final String project, final long score); }
LookupResultItem implements Comparable<LookupResultItem> { void combine(final LookupResultItem other) { if (other == null || !canBeCombinedWith(other)) { throw new IllegalArgumentException("Cannot combine with " + other); } projects.addAll(other.projects); score += other.score; } LookupResultItem(final String phrase, final String project, final long score); String getPhrase(); Set<String> getProjects(); long getScore(); @Override int compareTo(final LookupResultItem other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
LookupResultItem implements Comparable<LookupResultItem> { void combine(final LookupResultItem other) { if (other == null || !canBeCombinedWith(other)) { throw new IllegalArgumentException("Cannot combine with " + other); } projects.addAll(other.projects); score += other.score; } LookupResultItem(final String phrase, final String project, final long score); String getPhrase(); Set<String> getProjects(); long getScore(); @Override int compareTo(final LookupResultItem other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }