Skip to content

Commit 1aa16fa

Browse files
committed
ModuleSearcher: refactor matches method slightly
Let's avoid baking in the lower case assumption into the helper method.
1 parent aca5c36 commit 1aa16fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/scijava/search/module/ModuleSearcher.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ public List<SearchResult> search(final String text, final boolean fuzzy) {
8888

8989
// Next, add modules where title has text inside somewhere.
9090
modules.stream() //
91-
.filter(info -> matches(title(info), textLower)) //
91+
.filter(info -> matches(title(info).toLowerCase(), textLower)) //
9292
.forEach(matches::add);
9393

9494
// Finally, add modules where menu path has text inside somewhere.
9595
modules.stream() //
96-
.filter(info -> matches(info.getMenuPath().toString(), textLower)) //
96+
.filter(info -> matches(info.getMenuPath().toString().toLowerCase(),
97+
textLower)) //
9798
.forEach(matches::add);
9899

99100
// Wrap each matching ModuleInfo in a ModuleSearchResult.
@@ -159,6 +160,6 @@ private boolean isGoodModule(final ModuleInfo info) {
159160
private boolean matches(final String actual, final String desired) {
160161
// TODO: Implement fuzzy matching option, and maybe case sensitive option.
161162
// Probably put it in the SearchService itself, and make an API toggle.
162-
return actual.toLowerCase().matches(".*" + desired + ".*");
163+
return actual.matches(".*" + desired + ".*");
163164
}
164165
}

0 commit comments

Comments
 (0)