Skip to content

Commit fca7e1e

Browse files
Fix for add char and token filters in Luke Analysis tab (#14682)
1 parent b0f9923 commit fca7e1e

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Bug Fixes
116116
* GITHUB#14654: ValueSource.fromDoubleValuesSource(dvs).getSortField() would throw errors when
117117
used if the DoubleValuesSource needed scores. (David Smiley)
118118

119+
* GITHUB#14682 : Fix for add char and token filters in Luke Analysis tab. (Amir Raza)
120+
119121
Build
120122
---------------------
121123
* Upgrade forbiddenapis to version 3.9. (Uwe Schindler)

lucene/luke/src/java/org/apache/lucene/luke/app/desktop/util/ListUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.List;
2121
import java.util.function.IntFunction;
22+
import java.util.stream.Collectors;
2223
import java.util.stream.IntStream;
2324
import javax.swing.JList;
2425
import javax.swing.ListModel;
@@ -33,7 +34,7 @@ public static <T> List<T> getAllItems(JList<T> jlist) {
3334

3435
public static <T, R> List<R> getAllItems(JList<T> jlist, IntFunction<R> mapFunc) {
3536
ListModel<T> model = jlist.getModel();
36-
return IntStream.range(0, model.getSize()).mapToObj(mapFunc).toList();
37+
return IntStream.range(0, model.getSize()).mapToObj(mapFunc).collect(Collectors.toList());
3738
}
3839

3940
private ListUtils() {}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.lucene.luke.app.desktop.util;
19+
20+
import java.util.Arrays;
21+
import java.util.List;
22+
import javax.swing.JList;
23+
import org.apache.lucene.tests.util.LuceneTestCase;
24+
import org.junit.Test;
25+
26+
public class TestListUtils extends LuceneTestCase {
27+
28+
@Test
29+
public void testGetAllItems() {
30+
JList<String> list = new JList<>(new String[] {"Item 1", "Item 2"});
31+
List<String> items = ListUtils.getAllItems(list);
32+
assertEquals(Arrays.asList("Item 1", "Item 2"), items);
33+
// test mutability
34+
items.add("Item 3");
35+
assertEquals(Arrays.asList("Item 1", "Item 2", "Item 3"), items);
36+
}
37+
}

0 commit comments

Comments
 (0)