Skip to content

Commit b962a8f

Browse files
committed
SearchService: simplify duplication actions test
1 parent a1e19f4 commit b962a8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/scijava/search/SearchService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
package org.scijava.search;
3131

32-
import java.util.HashMap;
32+
import java.util.HashSet;
3333
import java.util.List;
34-
import java.util.Map;
34+
import java.util.Set;
3535
import java.util.stream.Collectors;
3636

3737
import org.scijava.plugin.SingletonService;
@@ -68,12 +68,12 @@ default SearchOperation search(final SearchListener... callbacks) {
6868
*/
6969
default List<SearchAction> actions(final SearchResult result) {
7070
// Create a map used to track whether a name has been seen
71-
final Map<Object, Boolean> seenLabels = new HashMap<>();
71+
final Set<String> seenLabels = new HashSet<>();
7272
return getInstances().stream() //
7373
.filter(factory -> factory.supports(result)) //
7474
.map(factory -> factory.create(result)) //
7575
// NB The following line skip actions with duplicate labels
76-
.filter(t -> seenLabels.putIfAbsent(t.toString(), Boolean.TRUE) == null) //
76+
.filter(t -> seenLabels.add(t.toString())) //
7777
.collect(Collectors.toList());
7878
}
7979

0 commit comments

Comments
 (0)