Skip to content

Commit 0111aa5

Browse files
committed
Fixed schemas sorting
1 parent 82e6847 commit 0111aa5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

api/src/main/java/io/kafbat/ui/service/index/NgramFilter.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,23 @@ public List<T> find(String search) {
3838
return find(search, true);
3939
}
4040

41+
private List<T> list(Stream<T> stream, boolean sort) {
42+
if (sort) {
43+
return stream.sorted().toList();
44+
} else {
45+
return stream.toList();
46+
}
47+
}
48+
4149
public List<T> find(String search, boolean sort) {
4250
if (search == null || search.isBlank()) {
43-
return this.getItems().stream().map(Tuple2::getT2).toList();
51+
return list(this.getItems().stream().map(Tuple2::getT2), sort);
4452
}
4553
if (!enabled) {
46-
Stream<T> stream = this.getItems()
54+
return list(this.getItems()
4755
.stream()
4856
.filter(t -> t.getT1().stream().anyMatch(s -> CI.contains(s, search)))
49-
.map(Tuple2::getT2);
50-
if (sort) {
51-
return stream.sorted().toList();
52-
} else {
53-
return stream.toList();
54-
}
57+
.map(Tuple2::getT2), sort);
5558
}
5659
try {
5760
List<SearchResult<T>> result = new ArrayList<>();

0 commit comments

Comments
 (0)