diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/AsyncParser.java b/jena-arq/src/main/java/org/apache/jena/riot/system/AsyncParser.java index 60f3bb0d736..1f35e9c8043 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/system/AsyncParser.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/system/AsyncParser.java @@ -28,8 +28,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; - import org.apache.jena.atlas.iterator.IteratorCloseable; import org.apache.jena.atlas.iterator.IteratorSlotted; import org.apache.jena.atlas.lib.InternalErrorException; @@ -189,7 +187,7 @@ public static AsyncParserBuilder ofSources(List sources) { private static List urlsToSource(List filesOrURLs) { return filesOrURLs.stream().map( uriOrFile -> RDFParser.source(uriOrFile).errorHandler(dftErrorHandler)) - .collect(Collectors.toList()); + .toList(); } /** Create a source object from the given arguments that is suitable for use with diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/OpAsQuery.java b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/OpAsQuery.java index 4b23ab44aa7..594139040cf 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/OpAsQuery.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/OpAsQuery.java @@ -20,8 +20,6 @@ import java.util.* ; import java.util.function.BiConsumer ; -import java.util.stream.Collectors ; - import org.apache.jena.atlas.lib.NotImplemented ; import org.apache.jena.graph.Node ; import org.apache.jena.graph.Triple ; @@ -116,12 +114,12 @@ void info() { if ( opHaving != null ) System.out.printf("having: %s\n", opHaving.getExprs()) ; if ( opExtends != null && !opExtends.isEmpty() ) { - List z = opExtends.stream().map(x -> x.getVarExprList()).collect(Collectors.toList()) ; + List z = opExtends.stream().map(x -> x.getVarExprList()).toList() ; System.out.printf("assigns: %s\n", z) ; } if ( opGroup != null ) { List aggregators = opGroup.getAggregators() ; - List aggVars = aggregators.stream().map(x -> x.getAggVar().asVar()).collect(Collectors.toList()) ; + List aggVars = aggregators.stream().map(x -> x.getAggVar().asVar()).toList() ; System.out.printf("group: %s |-| %s\n", opGroup.getGroupVars(), opGroup.getAggregators()) ; System.out.printf("group agg vars: %s\n", aggVars) ; } diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformFilterPlacement.java b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformFilterPlacement.java index 83d27e49716..88f6558eb6a 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformFilterPlacement.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformFilterPlacement.java @@ -666,7 +666,7 @@ private Placement placeDisjunction(ExprList exprs, OpDisjunction input) { if ( false ) { // Push everything, always - // Left as a safty fall back. + // Left as a safety fall back. List x = new ArrayList<>() ; input.getElements().forEach(op->{ Placement p = transform(exprs, op) ; @@ -683,7 +683,6 @@ private Placement placeDisjunction(ExprList exprs, OpDisjunction input) { // Don't push any expressions that aren't used in any of the arms of the disjunction. // This is more about being tidy. List unplaced = new ArrayList<>(exprs.getList()) ; - //List x = input.getElements().stream().map(op->transform(exprs, op)).collect(Collectors.toList()) ; List placements = new ArrayList<>(exprs.size()) ; Boolean someChange = Boolean.FALSE ; for ( Op op : input.getElements() ) { diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/exec/QueryExecDataset.java b/jena-arq/src/main/java/org/apache/jena/sparql/exec/QueryExecDataset.java index e2078a22476..d4029f39352 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/exec/QueryExecDataset.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/exec/QueryExecDataset.java @@ -22,8 +22,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; - import org.apache.jena.atlas.iterator.Iter; import org.apache.jena.atlas.json.JsonArray; import org.apache.jena.atlas.json.JsonObject; @@ -169,7 +167,7 @@ public RowSet select() { private RowSet execute() { startQueryIterator(); - List vars = query.getResultVars().stream().map(Var::alloc).collect(Collectors.toList()); + List vars = query.getResultVars().stream().map(Var::alloc).toList(); return RowSetStream.create(vars, queryIterator); } diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/modify/TemplateLib.java b/jena-arq/src/main/java/org/apache/jena/sparql/modify/TemplateLib.java index a20cc90807a..a9a9b880f13 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/modify/TemplateLib.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/modify/TemplateLib.java @@ -20,7 +20,6 @@ import java.util.*; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream ; import org.apache.jena.atlas.iterator.Iter; @@ -64,7 +63,7 @@ public static List remapDefaultGraph(List quads, final Node dftGraph Stream remappedStream = quads.stream().map(q-> !q.isDefaultGraph() ? q : new Quad(dftGraph, q.getSubject(), q.getPredicate(), q.getObject()) ) ; - return remappedStream.collect(Collectors.toList()); + return remappedStream.toList(); } /** Substitute into triple patterns */ diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java index 17b93b18c81..d1d50056c2e 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java @@ -20,7 +20,6 @@ import java.util.*; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.atlas.lib.SetUtils; import org.apache.jena.datatypes.RDFDatatype ; import org.apache.jena.datatypes.xsd.XSDDatatype ; @@ -107,9 +106,7 @@ public static List convertToListNodes(String... namedGraphs) { /** Convert strings to a List of {@link Node Nodes}. */ public static List convertToListNodes(List namedGraphs) { - List nodes = ListUtils.toList( - namedGraphs.stream().map(NodeFactory::createURI) - ); + List nodes = namedGraphs.stream().map(NodeFactory::createURI).toList(); return nodes; } diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java index fa057ebcc20..79daa39a150 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java @@ -24,7 +24,6 @@ import org.apache.jena.atlas.iterator.Iter; import org.apache.jena.atlas.lib.IRILib; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.datatypes.RDFDatatype; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; @@ -301,8 +300,7 @@ public static List findRootsByType(Model model, Resource atype) { QuerySolutionMap qsm = new QuerySolutionMap(); qsm.add("ATYPE", atype); try(QueryExecution qExec = QueryExecution.model(model).query(q).initialBinding(qsm).build() ) { - return ListUtils.toList( - QueryExecUtils.getAll(qExec, "root").stream().map(r->(Resource)r)); + return QueryExecUtils.getAll(qExec, "root").stream().map(r->(Resource)r).toList(); } } diff --git a/jena-arq/src/test/java/org/apache/jena/rdfs/LibTestRDFS.java b/jena-arq/src/test/java/org/apache/jena/rdfs/LibTestRDFS.java index 55dcf2cf79a..9a54af42aae 100644 --- a/jena-arq/src/test/java/org/apache/jena/rdfs/LibTestRDFS.java +++ b/jena-arq/src/test/java/org/apache/jena/rdfs/LibTestRDFS.java @@ -26,7 +26,6 @@ import org.apache.jena.atlas.iterator.Iter; import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.atlas.lib.Pair; -import org.apache.jena.atlas.lib.StreamOps; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.NodeFactory; @@ -43,7 +42,7 @@ public class LibTestRDFS { * Remove triples with a predicate which is RDFS schema vocabulary. */ public static List removeRDFS(List x) { - return StreamOps.toList(x.stream().filter(ConstRDFS.filterNotRDFS)); + return x.stream().filter(ConstRDFS.filterNotRDFS).toList(); } /** Create a Jena-rules backed graph */ diff --git a/jena-arq/src/test/java/org/apache/jena/rdfs/TestMatchVocab.java b/jena-arq/src/test/java/org/apache/jena/rdfs/TestMatchVocab.java index 655db60a638..de06bcfe822 100644 --- a/jena-arq/src/test/java/org/apache/jena/rdfs/TestMatchVocab.java +++ b/jena-arq/src/test/java/org/apache/jena/rdfs/TestMatchVocab.java @@ -24,16 +24,16 @@ import java.io.PrintStream; import java.util.List; +import org.junit.Assert; +import org.junit.Test; + import org.apache.jena.atlas.lib.ListUtils; -import org.apache.jena.atlas.lib.StreamOps; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.Triple; import org.apache.jena.rdfs.engine.ConstRDFS; import org.apache.jena.rdfs.setup.MatchVocabRDFS; import org.apache.jena.riot.RDFDataMgr; -import org.junit.Assert; -import org.junit.Test; /** Test the setup matcher that provides access to a setup as a (s,p,o) access */ public class TestMatchVocab { @@ -100,6 +100,6 @@ private void test(Node s, Node p, Node o) { } private List match(Node s, Node p, Node o) { - return StreamOps.toList(matchVocab.match(s, p, o)); + return matchVocab.match(s, p, o).toList(); } } diff --git a/jena-arq/src/test/java/org/apache/jena/riot/lang/rdfxml/rrx/RunTestRDFXML.java b/jena-arq/src/test/java/org/apache/jena/riot/lang/rdfxml/rrx/RunTestRDFXML.java index a66196e947f..590e0e44fb7 100644 --- a/jena-arq/src/test/java/org/apache/jena/riot/lang/rdfxml/rrx/RunTestRDFXML.java +++ b/jena-arq/src/test/java/org/apache/jena/riot/lang/rdfxml/rrx/RunTestRDFXML.java @@ -65,7 +65,7 @@ static List allTestFiles(Path DIR) { .filter(Files::isRegularFile) .map(Path::toString) .filter(fn->fn.endsWith(".rdf")) - .collect(Collectors.toList()); + .toList(); } catch (IOException ex) { throw IOX.exception(ex); } @@ -207,7 +207,7 @@ static List localTestFiles() { // If not enabling entity support in StAX //.filter(fn-> ( xmlParserType != XMLParser.StAX || !fn.startsWith("entities") ) ) .map(fn->LOCAL_DIR.resolve(fn).toString()) - .collect(Collectors.toList()); + .toList(); return testfilesAbs; } diff --git a/jena-arq/src/test/java/org/apache/jena/riot/system/TestAsyncParser.java b/jena-arq/src/test/java/org/apache/jena/riot/system/TestAsyncParser.java index c391e4c46ea..62647a1703e 100644 --- a/jena-arq/src/test/java/org/apache/jena/riot/system/TestAsyncParser.java +++ b/jena-arq/src/test/java/org/apache/jena/riot/system/TestAsyncParser.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.jena.atlas.iterator.IteratorCloseable; @@ -210,7 +209,7 @@ public void testNoEventsAreLost() { List expected; try (Stream s = AsyncParser.of(new ByteArrayInputStream(goodInputStr.getBytes()), Lang.TURTLE, null).streamElements()) { - expected = s.collect(Collectors.toList()); + expected = s.toList(); } // Validate parser on the good data @@ -225,7 +224,7 @@ public void testNoEventsAreLost() { try (Stream s = AsyncParser.of(new ByteArrayInputStream(badInputStr.getBytes()), Lang.TURTLE, null) .setChunkSize(chunkSize) .streamElements()) { - List actual = s.collect(Collectors.toList()); + List actual = s.toList(); Assert.assertEquals(expectedGoodEventCount + 1, actual.size()); Assert.assertEquals(expected, actual.subList(0, expectedGoodEventCount)); Assert.assertTrue(actual.get(actual.size() - 1).isException()); @@ -250,7 +249,7 @@ public void testPrematureDispatch() { }) .streamElements() .limit(1000)) { // The limit is just a safety net to prevent infinite parsing in case of malfunction - actual = stream.collect(Collectors.toList()); + actual = stream.toList(); } // Check that only the expected number of elements were dispatched diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionCancel.java b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionCancel.java index 1815e1a3060..8426349e70a 100644 --- a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionCancel.java +++ b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionCancel.java @@ -33,7 +33,6 @@ import java.util.concurrent.Future; import java.util.function.Consumer; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.IntStream; import org.apache.jena.graph.Graph; @@ -298,7 +297,7 @@ public static void runConcurrentAbort(int taskCount, int maxCancelDelay, Callabl Random cancelDelayRandom = new Random(); ExecutorService executorService = Executors.newCachedThreadPool(); try { - List list = IntStream.range(0, taskCount).boxed().collect(Collectors.toList()); + List list = IntStream.range(0, taskCount).boxed().toList(); list .parallelStream() .forEach(i -> { diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractDatasetGraphFind.java b/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractDatasetGraphFind.java index 93c61fcff18..2bc37ae7521 100644 --- a/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractDatasetGraphFind.java +++ b/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractDatasetGraphFind.java @@ -21,7 +21,6 @@ import static org.apache.jena.atlas.iterator.Iter.asStream ; import static org.apache.jena.atlas.iterator.Iter.toList; import static org.apache.jena.atlas.iterator.Iter.toSet; -import static org.apache.jena.atlas.lib.StreamOps.toList; import static org.junit.Assert.assertEquals ; import static org.junit.Assert.assertFalse ; import static org.junit.Assert.assertNotNull; @@ -29,8 +28,6 @@ import static org.junit.Assert.fail; import java.util.*; -import java.util.stream.Collectors ; - import org.apache.jena.atlas.iterator.Iter; import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.graph.Node ; @@ -205,7 +202,7 @@ protected DatasetGraphBaseFind createFind(DatasetGraph dsg) { assertEquals(3, x.size()) ; x.stream().allMatch(q->q.getGraph().equals(Quad.unionGraph)) ; - List z = x.stream().map(Quad::asTriple).collect(Collectors.toList()) ; + List z = x.stream().map(Quad::asTriple).toList(); assertTrue(z.contains(q4.asTriple())) ; assertTrue(z.contains(q5.asTriple())) ; Quad qx = Quad.create(Quad.unionGraph, q4.asTriple()) ; @@ -286,14 +283,14 @@ public void find_union_05() { } @Test public void stream_dsg_01() { - List x = toList(dsg.stream()); + List x = dsg.stream().toList(); assertEquals(10, x.size()) ; assertTrue(x.contains(q1)) ; assertTrue(x.contains(q5)) ; } @Test public void stream_dsg_02() { - List x = toList(dsg.stream(null, s,p,o)) ; + List x = dsg.stream(null, s,p,o).toList(); assertEquals(4, x.size()) ; assertFalse(x.contains(q2)) ; assertFalse(x.contains(q4)) ; @@ -312,7 +309,7 @@ private static String msg(String msg, List list1, List list2) { } static List quadsToDistinctTriples(Iterator iter) { - return asStream(iter).map(Quad::asTriple).distinct().collect(Collectors.toList()) ; + return asStream(iter).map(Quad::asTriple).distinct().toList() ; } static void print(List x) { diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/AbstractTestDistinctReduced.java b/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/AbstractTestDistinctReduced.java index 1b1f33a7d03..a0bf234ea30 100644 --- a/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/AbstractTestDistinctReduced.java +++ b/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/AbstractTestDistinctReduced.java @@ -21,8 +21,6 @@ import static org.junit.Assert.assertEquals; import java.util.*; -import java.util.stream.Collectors ; - import org.apache.jena.atlas.iterator.Iter ; import org.apache.jena.graph.NodeFactory ; import org.apache.jena.sparql.core.Var ; @@ -44,7 +42,7 @@ public abstract class AbstractTestDistinctReduced { private static List build(List items) { return items.stream().sequential() .map((s)-> BindingFactory.binding(var_a, NodeFactory.createLiteralString(s))) - .collect(Collectors.toList()); + .toList(); } protected abstract QueryIterator createQueryIter(List data) ; diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/TestDataBagDistinctOrder.java b/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/TestDataBagDistinctOrder.java index 3422b92faa4..4055dd55080 100644 --- a/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/TestDataBagDistinctOrder.java +++ b/jena-arq/src/test/java/org/apache/jena/sparql/engine/iterator/TestDataBagDistinctOrder.java @@ -21,8 +21,6 @@ import static org.junit.Assert.fail; import java.util.List ; -import java.util.stream.Collectors; - import org.apache.jena.atlas.lib.StrUtils; import org.apache.jena.query.*; import org.apache.jena.rdf.model.Model; @@ -50,7 +48,7 @@ public void distinctOrderSpill_1() { cxt.set(ARQ.spillToDiskThreshold, 2L); List x = ResultSetFormatter.toList(qExec.execSelect()); - List z = x.stream().map(qsoln->qsoln.getLiteral("v").getInt()).collect(Collectors.toList()); + List z = x.stream().map(qsoln->qsoln.getLiteral("v").getInt()).toList(); for ( int i = 0 ; i < z.size()-1; i++ ) { int v1 = z.get(i); int v2 = z.get(i+1); diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/Lib.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/Lib.java index bbc2b43b1a5..72c8c496c9c 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/Lib.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/Lib.java @@ -20,7 +20,6 @@ import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.stream.Stream; import java.util.zip.Adler32; import java.util.zip.CRC32; import java.util.zip.Checksum; @@ -54,12 +53,6 @@ public static String concatPaths(String directory, String path) { return directory+"/"+path; } - /** Stream to {@link List} */ - public static List toList(Stream stream) { - // Findability. - return StreamOps.toList(stream); - } - /** "ConcurrentHashSet" */ public static final Set concurrentHashSet() { return SetUtils.concurrentHashSet(); diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java index 490a1c83077..bde33c4d619 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java @@ -23,8 +23,7 @@ import java.util.ArrayList ; import java.util.List ; -import java.util.stream.Collectors ; -import java.util.stream.Stream ; +import java.util.stream.Stream; import org.apache.jena.atlas.io.IndentedWriter ; import org.apache.jena.atlas.logging.Log ; @@ -35,7 +34,7 @@ public class ListUtils private ListUtils() {} public static List unique(List list) { - return toList(list.stream().distinct()); + return list.stream().distinct().toList(); } public static List asList(int...values) { @@ -51,9 +50,10 @@ public static T last(List list) { return list.get(list.size()-1); } - // This is commonly needed + /** @deprecated Call {@link Stream#toList} */ + @Deprecated(forRemoval = true) public static List toList(Stream stream) { - return stream.collect(Collectors.toList()) ; + return stream.toList() ; } public static String str(T[] array) { diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/StrUtils.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/StrUtils.java index 45828d4c6df..7925ebfa7dc 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/StrUtils.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/StrUtils.java @@ -20,7 +20,6 @@ import static java.lang.String.format; import static java.util.Arrays.stream ; -import static java.util.stream.Collectors.toList; import java.nio.charset.StandardCharsets; import java.util.List; @@ -154,7 +153,7 @@ public static String noNewlineEnding(String x) { } public static List toCharList(String str) { - return str.codePoints().mapToObj(i -> (char) i).map(Character::valueOf).collect(toList()); + return str.codePoints().mapToObj(i -> (char) i).map(Character::valueOf).toList(); } // ==== Encoding and decoding strings based on a marker character (e.g. %) diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java index 36fcf0af0cb..b84be39e7ed 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java @@ -39,10 +39,10 @@ public static Stream stream(Iterator iter) { return Iter.asStream(iter); } - /** Stream to {@link List} */ - public static List toList(Stream stream) { - return stream.collect(Collectors.toList()); - } +// /** Stream to {@link List} */ +// public static List toList(Stream stream) { +// return stream.toList(); +// } /** Stream to {@link Set} */ public static Set toSet(Stream stream) { @@ -69,19 +69,19 @@ public static Stream print(Stream stream) { public static Stream print(PrintStream out, Stream stream) { stream = stream.map(item -> { out.println(item); return item; }); - return toList(stream).stream(); + return stream.toList().stream(); } public static Stream print(PrintStream out, String leader, Stream stream) { String prefix = (leader==null) ? "" : leader; stream = stream.map(item -> { out.print(prefix); out.println(item); return item; }); - return toList(stream).stream(); + return stream.toList().stream(); } /** Print immediate, noting empty streams */ public static Stream debug(Stream stream) { - List elts = StreamOps.toList(stream); + List elts = stream.toList(); if ( elts.isEmpty() ) System.out.println("[empty]"); else { @@ -91,5 +91,4 @@ public static Stream debug(Stream stream) { } return elts.stream(); } - } diff --git a/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java b/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java index 7b6869c2321..4dcde961351 100644 --- a/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java +++ b/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java @@ -21,7 +21,6 @@ import java.util.List ; import org.apache.jena.atlas.lib.IRILib; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.cmd.ArgDecl; import org.apache.jena.cmd.CmdArgModule; import org.apache.jena.cmd.CmdException; @@ -105,7 +104,7 @@ protected void addGraphs(Dataset ds) { } if ( hasEntries(graphURLs) || hasEntries(namedGraphURLs) ) { // Resolve named graph URLs so the graphname is an absolute IRI. - List x = ListUtils.toList(namedGraphURLs.stream().map(IRILib::filenameToIRI)); + List x = namedGraphURLs.stream().map(IRILib::filenameToIRI).toList(); DatasetUtils.addInGraphs(ds, graphURLs, x, null) ; } } diff --git a/jena-cmds/src/main/java/shacl/shacl_parse.java b/jena-cmds/src/main/java/shacl/shacl_parse.java index 6099cb0193e..aabdf892775 100644 --- a/jena-cmds/src/main/java/shacl/shacl_parse.java +++ b/jena-cmds/src/main/java/shacl/shacl_parse.java @@ -26,7 +26,6 @@ import org.apache.jena.atlas.io.IO; import org.apache.jena.atlas.io.IndentedWriter; -import org.apache.jena.atlas.lib.StreamOps; import org.apache.jena.atlas.logging.LogCtl; import org.apache.jena.cmd.ArgDecl; import org.apache.jena.cmd.CmdException; @@ -97,11 +96,10 @@ protected void processModulesAndArgs() { String[] a = x.split(","); return Arrays.stream(a); }; - List values = - StreamOps.toList(getValues(argOutput).stream() + List values = getValues(argOutput).stream() .flatMap(f) .map(s->s.toLowerCase()) - ); + .toList(); printText = values.remove("text") || values.remove("t"); printCompact = values.remove("compact") || values.remove("c"); printRDF = values.remove("rdf") || values.remove("r") || values.remove("ttl"); diff --git a/jena-cmds/src/main/java/shex/shex_parse.java b/jena-cmds/src/main/java/shex/shex_parse.java index e9fdf05dddd..c694861a278 100644 --- a/jena-cmds/src/main/java/shex/shex_parse.java +++ b/jena-cmds/src/main/java/shex/shex_parse.java @@ -27,7 +27,6 @@ import org.apache.jena.atlas.io.IndentedWriter; import org.apache.jena.atlas.lib.FileOps; -import org.apache.jena.atlas.lib.StreamOps; import org.apache.jena.atlas.logging.LogCtl; import org.apache.jena.cmd.ArgDecl; import org.apache.jena.cmd.CmdException; @@ -90,11 +89,10 @@ protected void processModulesAndArgs() { String[] a = x.split(","); return Arrays.stream(a); }; - List values = - StreamOps.toList(getValues(argOutput).stream() + List values = getValues(argOutput).stream() .flatMap(f) .map(s->s.toLowerCase()) - ); + .toList(); printText = values.remove("text") || values.remove("t"); printCompact = values.remove("compact") || values.remove("c"); printRDF = values.remove("rdf") || values.remove("r"); diff --git a/jena-cmds/src/main/java/tdb/tdbloader.java b/jena-cmds/src/main/java/tdb/tdbloader.java index ff51b45d38f..331fc04a574 100644 --- a/jena-cmds/src/main/java/tdb/tdbloader.java +++ b/jena-cmds/src/main/java/tdb/tdbloader.java @@ -23,7 +23,6 @@ import java.nio.file.Paths; import java.util.List; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.cmd.ArgDecl; import org.apache.jena.cmd.CmdException; import org.apache.jena.query.ARQ; @@ -127,13 +126,13 @@ protected void exec() { // Check files exists before starting. private void checkFiles(List urls) { - List problemFiles = ListUtils.toList(urls.stream().filter(u -> FileUtils.isFile(u)) + List problemFiles = urls.stream().filter(u -> FileUtils.isFile(u)) // Only check local files. .map(Paths::get) - .filter(p -> !Files.exists(p) || !Files.isRegularFile(p /* follow - * links */) - || !Files.isReadable(p)) - .map(Path::toString)); + /* follows links */ + .filter(p -> !Files.exists(p) || !Files.isRegularFile(p) || !Files.isReadable(p)) + .map(Path::toString) + .toList(); if ( !problemFiles.isEmpty() ) { String str = String.join(", ", problemFiles); throw new CmdException("Can't read files : " + str); diff --git a/jena-cmds/src/main/java/tdb2/tdbloader.java b/jena-cmds/src/main/java/tdb2/tdbloader.java index 0a41548577d..86d86f562ab 100644 --- a/jena-cmds/src/main/java/tdb2/tdbloader.java +++ b/jena-cmds/src/main/java/tdb2/tdbloader.java @@ -18,8 +18,6 @@ package tdb2; -import static org.apache.jena.atlas.lib.ListUtils.toList; - import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -160,14 +158,15 @@ protected void exec() { // Check files exists before starting. private void checkFiles(List urls) { - List problemFiles = toList(urls.stream() + List problemFiles = urls.stream() // Local files. .filter(u -> FileUtils.isFile(u)) .map(Paths::get) .filter(p -> !Files.exists(p) || !Files.isRegularFile(p /* this follows links */) || !Files.isReadable(p)) - .map(Path::toString)); + .map(Path::toString) + .toList(); if ( !problemFiles.isEmpty() ) { if ( problemFiles.size() == 1 ) throw new CmdException("Can't read file : " + problemFiles.get(0)); diff --git a/jena-core/src/test/java/org/apache/jena/mem2/AbstractGraphMem2Test.java b/jena-core/src/test/java/org/apache/jena/mem2/AbstractGraphMem2Test.java index b05a4e7d5ce..58819cc1f5e 100644 --- a/jena-core/src/test/java/org/apache/jena/mem2/AbstractGraphMem2Test.java +++ b/jena-core/src/test/java/org/apache/jena/mem2/AbstractGraphMem2Test.java @@ -18,20 +18,21 @@ package org.apache.jena.mem2; +import static org.apache.jena.testing_framework.GraphHelper.node; +import static org.apache.jena.testing_framework.GraphHelper.triple; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + import org.apache.jena.datatypes.xsd.impl.XSDDouble; import org.apache.jena.graph.NodeFactory; import org.apache.jena.graph.Triple; import org.hamcrest.collection.IsEmptyCollection; import org.hamcrest.collection.IsIterableContainingInAnyOrder; -import org.junit.Before; -import org.junit.Test; - -import java.util.stream.Collectors; - -import static org.apache.jena.testing_framework.GraphHelper.node; -import static org.apache.jena.testing_framework.GraphHelper.triple; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.*; public abstract class AbstractGraphMem2Test { @@ -379,7 +380,7 @@ public void testStreamSPO() { var t = triple("x R y"); sut.add(t); - var findings = sut.stream(t.getSubject(), t.getPredicate(), t.getObject()).collect(Collectors.toList()); + var findings = sut.stream(t.getSubject(), t.getPredicate(), t.getObject()).toList(); assertEquals(1, findings.size()); assertEquals(findings.get(0), t); } @@ -408,7 +409,7 @@ public void testStream___() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(null, null, null).collect(Collectors.toList()); + var findings = sut.stream(null, null, null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc, bAa, bAb, bAc, cBa, cBb, cBc)); } @@ -436,16 +437,16 @@ public void testStreamS__() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(aAa.getSubject(), null, null).collect(Collectors.toList()); + var findings = sut.stream(aAa.getSubject(), null, null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc)); - findings = sut.stream(bAa.getSubject(), null, null).collect(Collectors.toList()); + findings = sut.stream(bAa.getSubject(), null, null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(bAa, bAb, bAc)); - findings = sut.stream(cBa.getSubject(), null, null).collect(Collectors.toList()); + findings = sut.stream(cBa.getSubject(), null, null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa, cBb, cBc)); - findings = sut.stream(node("d"), null, null).collect(Collectors.toList()); + findings = sut.stream(node("d"), null, null).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -473,13 +474,13 @@ public void testStream_P_() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(null, aAa.getPredicate(), null).collect(Collectors.toList()); + var findings = sut.stream(null, aAa.getPredicate(), null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc, bAa, bAb, bAc)); - findings = sut.stream(null, cBa.getPredicate(), null).collect(Collectors.toList()); + findings = sut.stream(null, cBa.getPredicate(), null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa, cBb, cBc)); - findings = sut.stream(null, node("C"), null).collect(Collectors.toList()); + findings = sut.stream(null, node("C"), null).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -507,16 +508,16 @@ public void testStream__O() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(null, null, aAa.getObject()).collect(Collectors.toList()); + var findings = sut.stream(null, null, aAa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, bAa, cBa)); - findings = sut.stream(null, null, aAb.getObject()).collect(Collectors.toList()); + findings = sut.stream(null, null, aAb.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAb, bAb, cBb)); - findings = sut.stream(null, null, aAc.getObject()).collect(Collectors.toList()); + findings = sut.stream(null, null, aAc.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAc, bAc, cBc)); - findings = sut.stream(null, null, node("d")).collect(Collectors.toList()); + findings = sut.stream(null, null, node("d")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -544,19 +545,19 @@ public void testStreamSP_() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(aAa.getSubject(), aAa.getPredicate(), null).collect(Collectors.toList()); + var findings = sut.stream(aAa.getSubject(), aAa.getPredicate(), null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc)); - findings = sut.stream(bAa.getSubject(), bAa.getPredicate(), null).collect(Collectors.toList()); + findings = sut.stream(bAa.getSubject(), bAa.getPredicate(), null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(bAa, bAb, bAc)); - findings = sut.stream(cBa.getSubject(), cBa.getPredicate(), null).collect(Collectors.toList()); + findings = sut.stream(cBa.getSubject(), cBa.getPredicate(), null).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa, cBb, cBc)); - findings = sut.stream(node("a"), node("C"), null).collect(Collectors.toList()); + findings = sut.stream(node("a"), node("C"), null).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(node("d"), node("D"), null).collect(Collectors.toList()); + findings = sut.stream(node("d"), node("D"), null).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -584,22 +585,22 @@ public void testStreamS_O() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(aAa.getSubject(), null, aAa.getObject()).collect(Collectors.toList()); + var findings = sut.stream(aAa.getSubject(), null, aAa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa)); - findings = sut.stream(bAa.getSubject(), null, bAa.getObject()).collect(Collectors.toList()); + findings = sut.stream(bAa.getSubject(), null, bAa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(bAa)); - findings = sut.stream(cBa.getSubject(), null, cBa.getObject()).collect(Collectors.toList()); + findings = sut.stream(cBa.getSubject(), null, cBa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa)); - findings = sut.stream(node("d"), null, node("d")).collect(Collectors.toList()); + findings = sut.stream(node("d"), null, node("d")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(node("d"), null, node("a")).collect(Collectors.toList()); + findings = sut.stream(node("d"), null, node("a")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(node("a"), null, node("d")).collect(Collectors.toList()); + findings = sut.stream(node("a"), null, node("d")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -627,22 +628,22 @@ public void testStream_PO() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(null, aAa.getPredicate(), aAa.getObject()).collect(Collectors.toList()); + var findings = sut.stream(null, aAa.getPredicate(), aAa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, bAa)); - findings = sut.stream(null, bAa.getPredicate(), bAa.getObject()).collect(Collectors.toList()); + findings = sut.stream(null, bAa.getPredicate(), bAa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, bAa)); - findings = sut.stream(null, cBa.getPredicate(), cBa.getObject()).collect(Collectors.toList()); + findings = sut.stream(null, cBa.getPredicate(), cBa.getObject()).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa)); - findings = sut.stream(null, node("C"), node("a")).collect(Collectors.toList()); + findings = sut.stream(null, node("C"), node("a")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(null, node("A"), node("d")).collect(Collectors.toList()); + findings = sut.stream(null, node("A"), node("d")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(null, node("D"), node("d")).collect(Collectors.toList()); + findings = sut.stream(null, node("D"), node("d")).toList(); assertThat(findings, IsEmptyCollection.empty()); } diff --git a/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaMapNodeTest.java b/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaMapNodeTest.java index 69ba1bc9f95..8381c619284 100644 --- a/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaMapNodeTest.java +++ b/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaMapNodeTest.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.ConcurrentModificationException; import java.util.NoSuchElementException; -import java.util.stream.Collectors; import java.util.stream.StreamSupport; import static org.apache.jena.testing_framework.GraphHelper.node; @@ -305,7 +304,7 @@ public void testKeySpliterator1() { sut.put(n0, null); final var spliterator = sut.keySpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(n0)); } @@ -314,7 +313,7 @@ public void testValueSpliterator1() { sut.put(node("s"), 1); final var spliterator = sut.valueSpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(1)); } @@ -327,7 +326,7 @@ public void testKeySpliterator2() { sut.put(n1, null); final var spliterator = sut.keySpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1)); } @@ -337,7 +336,7 @@ public void testValueSpliterator2() { sut.put(node("s2"), 2); final var spliterator = sut.valueSpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2)); } @@ -352,7 +351,7 @@ public void testKeySpliterator3() { sut.put(n2, null); final var spliterator = sut.keySpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1, n2)); } @@ -363,20 +362,20 @@ public void testValueSpliterator3() { sut.put(node("s3"), 3); final var spliterator = sut.valueSpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2, 3)); } @Test public void testKeyStreamEmpty() { var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsEmptyCollection.empty()); + assertThat(stream.toList(), IsEmptyCollection.empty()); } @Test public void testValueStreamEmpty() { var stream = sut.valueStream(); - assertThat(stream.collect(Collectors.toList()), IsEmptyCollection.empty()); + assertThat(stream.toList(), IsEmptyCollection.empty()); } @Test @@ -386,7 +385,7 @@ public void testKeyStream1() { sut.put(n0, null); final var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(n0)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(n0)); } @Test @@ -394,7 +393,7 @@ public void testValueStream1() { sut.put(node("s"), 1); final var stream = sut.valueStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(1)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(1)); } @Test @@ -406,7 +405,7 @@ public void testKeyStream2() { sut.put(n1, null); final var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1)); } @Test @@ -415,7 +414,7 @@ public void testValueStream2() { sut.put(node("s2"), 2); final var stream = sut.valueStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2)); } @Test @@ -429,7 +428,7 @@ public void testKeyStream3() { sut.put(n2, null); final var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1, n2)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1, n2)); } @Test @@ -439,19 +438,19 @@ public void testValueStream3() { sut.put(node("s3"), 3); final var stream = sut.valueStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2, 3)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2, 3)); } @Test public void testKeyStreamParallelEmpty() { var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsEmptyCollection.empty()); + assertThat(stream.toList(), IsEmptyCollection.empty()); } @Test public void testValueStreamParallelEmpty() { var stream = sut.valueStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsEmptyCollection.empty()); + assertThat(stream.toList(), IsEmptyCollection.empty()); } @Test @@ -461,7 +460,7 @@ public void testKeyStreamParallel1() { sut.put(n0, null); final var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(n0)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(n0)); } @Test @@ -469,7 +468,7 @@ public void testValueStreamParallel1() { sut.put(node("s"), 1); final var stream = sut.valueStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(1)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(1)); } @Test @@ -481,7 +480,7 @@ public void testKeyStreamParallel2() { sut.put(n1, null); final var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1)); } @Test @@ -490,7 +489,7 @@ public void testValueStreamParallel2() { sut.put(node("s2"), 2); final var stream = sut.valueStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2)); } @Test @@ -504,7 +503,7 @@ public void testKeyStreamParallel3() { sut.put(n2, null); final var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1, n2)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(n0, n1, n2)); } @Test @@ -514,7 +513,7 @@ public void testValueStreamParallel3() { sut.put(node("s3"), 3); final var stream = sut.valueStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2, 3)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(1, 2, 3)); } @Test diff --git a/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaSetTripleTest.java b/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaSetTripleTest.java index 7e810a9d450..1f4bbdb83b7 100644 --- a/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaSetTripleTest.java +++ b/jena-core/src/test/java/org/apache/jena/mem2/collection/AbstractJenaSetTripleTest.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.ConcurrentModificationException; import java.util.NoSuchElementException; -import java.util.stream.Collectors; import java.util.stream.StreamSupport; import static org.apache.jena.testing_framework.GraphHelper.triple; @@ -174,7 +173,7 @@ public void testKeySpliterator1() { sut.tryAdd(t0); final var spliterator = sut.keySpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(t0)); } @@ -187,7 +186,7 @@ public void testKeySpliterator2() { sut.tryAdd(t1); final var spliterator = sut.keySpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1)); } @@ -202,14 +201,14 @@ public void testKeySpliterator3() { sut.tryAdd(t2); final var spliterator = sut.keySpliterator(); - final var list = StreamSupport.stream(spliterator, false).collect(Collectors.toList()); + final var list = StreamSupport.stream(spliterator, false).toList(); assertThat(list, IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1, t2)); } @Test public void testKeyStreamEmpty() { var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsEmptyCollection.empty()); + assertThat(stream.toList(), IsEmptyCollection.empty()); } @Test @@ -219,7 +218,7 @@ public void testKeyStream1() { sut.tryAdd(t0); final var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(t0)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(t0)); } @Test @@ -231,7 +230,7 @@ public void testKeyStream2() { sut.tryAdd(t1); final var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1)); } @Test @@ -245,13 +244,13 @@ public void testKeyStream3() { sut.tryAdd(t2); final var stream = sut.keyStream(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1, t2)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1, t2)); } @Test public void testKeyStreamParallelEmpty() { var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsEmptyCollection.empty()); + assertThat(stream.toList(), IsEmptyCollection.empty()); } @Test @@ -261,7 +260,7 @@ public void testKeyStreamParallel1() { sut.tryAdd(t0); final var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(t0)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(t0)); } @Test @@ -273,7 +272,7 @@ public void testKeyStreamParallel2() { sut.tryAdd(t1); final var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1)); } @Test @@ -287,7 +286,7 @@ public void testKeyStreamParallel3() { sut.tryAdd(t2); final var stream = sut.keyStreamParallel(); - assertThat(stream.collect(Collectors.toList()), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1, t2)); + assertThat(stream.toList(), IsIterableContainingInAnyOrder.containsInAnyOrder(t0, t1, t2)); } @Test diff --git a/jena-core/src/test/java/org/apache/jena/mem2/store/AbstractTripleStoreTest.java b/jena-core/src/test/java/org/apache/jena/mem2/store/AbstractTripleStoreTest.java index 89114a48f1b..9d7023ec3b7 100644 --- a/jena-core/src/test/java/org/apache/jena/mem2/store/AbstractTripleStoreTest.java +++ b/jena-core/src/test/java/org/apache/jena/mem2/store/AbstractTripleStoreTest.java @@ -26,8 +26,6 @@ import org.junit.Before; import org.junit.Test; -import java.util.stream.Collectors; - import static org.apache.jena.testing_framework.GraphHelper.node; import static org.apache.jena.testing_framework.GraphHelper.triple; import static org.hamcrest.MatcherAssert.assertThat; @@ -380,7 +378,7 @@ public void testStreamSPO() { var t = triple("x R y"); sut.add(t); - var findings = sut.stream(t).collect(Collectors.toList()); + var findings = sut.stream(t).toList(); assertEquals(1, findings.size()); assertEquals(findings.get(0), t); } @@ -409,7 +407,7 @@ public void testStream___() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(triple("?? ?? ??")).collect(Collectors.toList()); + var findings = sut.stream(triple("?? ?? ??")).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc, bAa, bAb, bAc, cBa, cBb, cBc)); } @@ -437,16 +435,16 @@ public void testStreamS__() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(Triple.createMatch(aAa.getSubject(), null, null)).collect(Collectors.toList()); + var findings = sut.stream(Triple.createMatch(aAa.getSubject(), null, null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc)); - findings = sut.stream(Triple.createMatch(bAa.getSubject(), null, null)).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(bAa.getSubject(), null, null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(bAa, bAb, bAc)); - findings = sut.stream(Triple.createMatch(cBa.getSubject(), null, null)).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(cBa.getSubject(), null, null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa, cBb, cBc)); - findings = sut.stream(triple("d ?? ??")).collect(Collectors.toList()); + findings = sut.stream(triple("d ?? ??")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -474,13 +472,13 @@ public void testStream_P_() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(Triple.createMatch(null, aAa.getPredicate(), null)).collect(Collectors.toList()); + var findings = sut.stream(Triple.createMatch(null, aAa.getPredicate(), null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc, bAa, bAb, bAc)); - findings = sut.stream(Triple.createMatch(null, cBa.getPredicate(), null)).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(null, cBa.getPredicate(), null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa, cBb, cBc)); - findings = sut.stream(triple("?? C ??")).collect(Collectors.toList()); + findings = sut.stream(triple("?? C ??")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -508,16 +506,16 @@ public void testStream__O() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(Triple.createMatch(null, null, aAa.getObject())).collect(Collectors.toList()); + var findings = sut.stream(Triple.createMatch(null, null, aAa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, bAa, cBa)); - findings = sut.stream(Triple.createMatch(null, null, aAb.getObject())).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(null, null, aAb.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAb, bAb, cBb)); - findings = sut.stream(Triple.createMatch(null, null, aAc.getObject())).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(null, null, aAc.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAc, bAc, cBc)); - findings = sut.stream(triple("?? ?? d")).collect(Collectors.toList()); + findings = sut.stream(triple("?? ?? d")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -545,19 +543,19 @@ public void testStreamSP_() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(Triple.createMatch(aAa.getSubject(), aAa.getPredicate(), null)).collect(Collectors.toList()); + var findings = sut.stream(Triple.createMatch(aAa.getSubject(), aAa.getPredicate(), null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, aAb, aAc)); - findings = sut.stream(Triple.createMatch(bAa.getSubject(), bAa.getPredicate(), null)).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(bAa.getSubject(), bAa.getPredicate(), null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(bAa, bAb, bAc)); - findings = sut.stream(Triple.createMatch(cBa.getSubject(), cBa.getPredicate(), null)).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(cBa.getSubject(), cBa.getPredicate(), null)).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa, cBb, cBc)); - findings = sut.stream(triple("a C ??")).collect(Collectors.toList()); + findings = sut.stream(triple("a C ??")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(triple("d D ??")).collect(Collectors.toList()); + findings = sut.stream(triple("d D ??")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -585,22 +583,22 @@ public void testStreamS_O() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(Triple.createMatch(aAa.getSubject(), null, aAa.getObject())).collect(Collectors.toList()); + var findings = sut.stream(Triple.createMatch(aAa.getSubject(), null, aAa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa)); - findings = sut.stream(Triple.createMatch(bAa.getSubject(), null, bAa.getObject())).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(bAa.getSubject(), null, bAa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(bAa)); - findings = sut.stream(Triple.createMatch(cBa.getSubject(), null, cBa.getObject())).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(cBa.getSubject(), null, cBa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa)); - findings = sut.stream(triple("d ?? d")).collect(Collectors.toList()); + findings = sut.stream(triple("d ?? d")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(triple("d ?? a")).collect(Collectors.toList()); + findings = sut.stream(triple("d ?? a")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(triple("a ?? d")).collect(Collectors.toList()); + findings = sut.stream(triple("a ?? d")).toList(); assertThat(findings, IsEmptyCollection.empty()); } @@ -628,22 +626,22 @@ public void testStream_PO() { sut.add(cBb); sut.add(cBc); - var findings = sut.stream(Triple.createMatch(null, aAa.getPredicate(), aAa.getObject())).collect(Collectors.toList()); + var findings = sut.stream(Triple.createMatch(null, aAa.getPredicate(), aAa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, bAa)); - findings = sut.stream(Triple.createMatch(null, bAa.getPredicate(), bAa.getObject())).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(null, bAa.getPredicate(), bAa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(aAa, bAa)); - findings = sut.stream(Triple.createMatch(null, cBa.getPredicate(), cBa.getObject())).collect(Collectors.toList()); + findings = sut.stream(Triple.createMatch(null, cBa.getPredicate(), cBa.getObject())).toList(); assertThat(findings, IsIterableContainingInAnyOrder.containsInAnyOrder(cBa)); - findings = sut.stream(triple("?? C a")).collect(Collectors.toList()); + findings = sut.stream(triple("?? C a")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(triple("?? A d")).collect(Collectors.toList()); + findings = sut.stream(triple("?? A d")).toList(); assertThat(findings, IsEmptyCollection.empty()); - findings = sut.stream(triple("?? D d")).collect(Collectors.toList()); + findings = sut.stream(triple("?? D d")).toList(); assertThat(findings, IsEmptyCollection.empty()); } diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java index 530e9ba8899..bc30709e765 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java @@ -27,8 +27,6 @@ import org.junit.Test; import java.util.List; -import java.util.stream.Collectors; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; @@ -72,6 +70,6 @@ public void load_from_file_bad_encoding() { public void load_from_file_with_custom_builtins() { BuiltinRegistry br = createBuiltinRegistry(); List rules = Rule.rulesFromURL("testing/reasoners/bugs/custom-builtins.rules", br); - assertEquals(List.of("ruleWithBuiltin"), rules.stream().map(Rule::getName).collect(Collectors.toList())); + assertEquals(List.of("ruleWithBuiltin"), rules.stream().map(Rule::getName).toList()); } } diff --git a/jena-db/jena-dboe-storage/src/main/java/org/apache/jena/dboe/storage/simple/StorageTuplesN.java b/jena-db/jena-dboe-storage/src/main/java/org/apache/jena/dboe/storage/simple/StorageTuplesN.java index 5448de66406..2276d54fdbc 100644 --- a/jena-db/jena-dboe-storage/src/main/java/org/apache/jena/dboe/storage/simple/StorageTuplesN.java +++ b/jena-db/jena-dboe-storage/src/main/java/org/apache/jena/dboe/storage/simple/StorageTuplesN.java @@ -23,7 +23,6 @@ import java.util.Set; import java.util.stream.Stream; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.atlas.lib.tuple.Tuple; import org.apache.jena.graph.Node; import org.apache.jena.sparql.core.Match; @@ -50,7 +49,7 @@ public void delete(Tuple terms) { } public void removeAll(Tuple pattern) { - List> acc = ListUtils.toList(find(pattern)); + List> acc = find(pattern).toList(); acc.stream().forEach(this::delete); } diff --git a/jena-db/jena-dboe-trans-data/src/main/java/org/apache/jena/dboe/trans/bplustree/AccessPath.java b/jena-db/jena-dboe-trans-data/src/main/java/org/apache/jena/dboe/trans/bplustree/AccessPath.java index bc124b21caf..c4e4ea5241c 100644 --- a/jena-db/jena-dboe-trans-data/src/main/java/org/apache/jena/dboe/trans/bplustree/AccessPath.java +++ b/jena-db/jena-dboe-trans-data/src/main/java/org/apache/jena/dboe/trans/bplustree/AccessPath.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; - import org.apache.jena.atlas.lib.InternalErrorException; public class AccessPath { @@ -64,7 +62,7 @@ public void reset(BPTreeNode node, int idx, BPTreePage page) { @Override public String toString() { - return traversed.stream().map(x-> x.toString()).collect(Collectors.toList()).toString(); + return traversed.stream().map(x-> x.toString()).toList().toString(); } } diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java index 7acc0b6e555..2adb439e805 100644 --- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java +++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java @@ -19,8 +19,6 @@ import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; - import org.apache.jena.arq.querybuilder.clauses.WhereClause; import org.apache.jena.graph.Node; import org.apache.jena.shared.PrefixMapping; @@ -1599,7 +1597,7 @@ public final ExprVar asVar(Object o) { */ public final ExprList asList(Object... args) { // make sure the list is modifyable - List lst = Arrays.asList(args).stream().map(arg -> asExpr(arg)).collect(Collectors.toList()); + List lst = Arrays.asList(args).stream().map(arg -> asExpr(arg)).toList(); return new ExprList(lst); } diff --git a/jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerBatcher.java b/jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerBatcher.java index 860e7210f8c..86b91248a27 100644 --- a/jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerBatcher.java +++ b/jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerBatcher.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Random; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.jena.atlas.iterator.Iter; @@ -100,8 +99,8 @@ public static void eval( // For each obtained batch extract the list of values List> actualBatchIds = Streams.stream(it) - .map(groupedBatch -> groupedBatch.getBatch().getItems().values().stream().map(Entry::getValue).collect(Collectors.toList())) - .collect(Collectors.toList()); + .map(groupedBatch -> groupedBatch.getBatch().getItems().values().stream().map(Entry::getValue).toList()) + .toList(); Assert.assertEquals(expectedBatchIds, actualBatchIds); } diff --git a/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB1.java b/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB1.java index 120f57d6050..71fe0c5a2b8 100644 --- a/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB1.java +++ b/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB1.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Objects; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.graph.Node; import org.apache.jena.sparql.core.DatasetGraph; import org.apache.jena.sparql.util.Symbol; @@ -55,12 +54,10 @@ public static GraphFilterTDB1 graphFilter(DatasetGraph dsg, Collection nam List x = Txn.calculateRead(dsg, ()->{ NodeTable nt = TDBInternal.getDatasetGraphTDB(dsg).getQuadTable().getNodeTupleTable().getNodeTable(); - return - ListUtils.toList( - namedGraphs.stream() + return namedGraphs.stream() .map(n->nt.getNodeIdForNode(n)) .filter(Objects::nonNull) - ); + .toList(); }); return new GraphFilterTDB1(x, matchDefaultGraph); } diff --git a/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB2.java b/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB2.java index 6ecab6c7507..01268a32215 100644 --- a/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB2.java +++ b/jena-fuseki2/jena-fuseki-access/src/main/java/org/apache/jena/fuseki/access/GraphFilterTDB2.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Objects; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.graph.Node; import org.apache.jena.sparql.core.DatasetGraph; import org.apache.jena.sparql.util.Symbol; @@ -55,12 +54,10 @@ public static GraphFilterTDB2 graphFilter(DatasetGraph dsg, Collection nam List x = Txn.calculateRead(dsg, ()->{ NodeTable nt = TDBInternal.getDatasetGraphTDB(dsg).getQuadTable().getNodeTupleTable().getNodeTable(); - return - ListUtils.toList( - namedGraphs.stream() + return namedGraphs.stream() .map(n->nt.getNodeIdForNode(n)) .filter(Objects::nonNull) - ); + .toList(); }); return new GraphFilterTDB2(x, matchDefaultGraph); } diff --git a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/sys/FusekiAutoModules.java b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/sys/FusekiAutoModules.java index 83c65232421..80e5a368e00 100644 --- a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/sys/FusekiAutoModules.java +++ b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/sys/FusekiAutoModules.java @@ -23,8 +23,6 @@ import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.function.Function; -import java.util.stream.Collectors; - import org.apache.jena.atlas.lib.Lib; import org.apache.jena.atlas.lib.Version; import org.apache.jena.atlas.logging.FmtLog; @@ -207,12 +205,12 @@ private FusekiModules load() { .map(mapper) .filter(Objects::nonNull) .sorted((x,y)-> Integer.compare(x.level(), y.level())) - .collect(Collectors.toList()); + .toList(); // Start, and convert to FusekiModules (generics issue) List fmods = autoMods.stream().map(afmod->{ afmod.start(); - return afmod; - }).collect(Collectors.toList()); + return (FusekiModule)afmod; + }).toList(); fmods.forEach(m->{ String name = m.name(); diff --git a/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java b/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java index 3e67c252608..ac5b3e5b2a4 100644 --- a/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java +++ b/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java @@ -27,8 +27,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; - import org.apache.jena.atlas.json.JsonBuilder; import org.apache.jena.atlas.json.JsonValue; import org.apache.jena.fuseki.ctl.ActionCtl; @@ -78,7 +76,7 @@ private JsonValue description(HttpAction action) { ServletOps.errorOccurred(ex); } - List fileNames = paths.stream().map((p)->p.getFileName().toString()).sorted().collect(Collectors.toList()); + List fileNames = paths.stream().map((p)->p.getFileName().toString()).sorted().toList(); JsonBuilder builder = new JsonBuilder(); builder.startObject("top"); diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java index d7a29797406..28ffc8085bc 100644 --- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java +++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.stream.Collectors; import org.apache.jena.geosparql.implementation.GeometryWrapper; import org.apache.jena.geosparql.implementation.vocabulary.Geo; import org.apache.jena.geosparql.implementation.vocabulary.SRS_URI; @@ -82,7 +81,7 @@ public void search(Model model) { } } - srsList = srsMap.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).collect(Collectors.toList()); + srsList = srsMap.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).toList(); } public List> getSrsList() { diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/Imports.java b/jena-shacl/src/main/java/org/apache/jena/shacl/Imports.java index 04416df3eaa..b0d79ca3ce9 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/Imports.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/Imports.java @@ -26,8 +26,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; - import org.apache.jena.atlas.lib.Pair; import org.apache.jena.atlas.logging.FmtLog; import org.apache.jena.atlas.web.HttpException; @@ -203,7 +201,7 @@ public static Node base(Graph graph) { * indicating "any owl:imports". */ public static List allImports(Node base, Graph graph) { - List imports = iter(G.listSP(graph, base, nodeOwlImports)).filter(Node::isURI).collect(Collectors.toList()); + List imports = iter(G.listSP(graph, base, nodeOwlImports)).filter(Node::isURI).toList(); return imports; } } diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java b/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java index 8ab775a2c9e..5eeaaa73954 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java @@ -20,8 +20,6 @@ import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; - import org.apache.jena.atlas.io.IndentedLineBuffer; import org.apache.jena.atlas.io.IndentedWriter; import org.apache.jena.atlas.lib.CollectionUtils; @@ -139,10 +137,10 @@ private static PrefixMap prefixMapWithStd(PrefixMapping prefixMapping) { public static void output(IndentedWriter out, NodeFormatter nodeFmt, ShapeOutputVisitor visitor, Shape sh) { List targetImplicitClasses = sh.getTargets().stream() .filter(t->t.getTargetType()==TargetType.implicitClass) - .collect(Collectors.toList()); + .toList(); List targetClasses = sh.getTargets().stream() .filter(t->t.getTargetType()==TargetType.targetClass) - .collect(Collectors.toList()); + .toList(); if ( targetImplicitClasses.isEmpty() ) { out.print("shape "); diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/SparqlComponent.java b/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/SparqlComponent.java index a21e5b50953..64fadb99de6 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/SparqlComponent.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/SparqlComponent.java @@ -18,8 +18,6 @@ package org.apache.jena.shacl.engine.constraint; -import static java.util.stream.Collectors.toList; - import java.util.List; import java.util.Objects; @@ -58,11 +56,11 @@ private SparqlComponent(String sparqlString, List params, Node report this.requiredParameters = params.stream() .filter(param->!param.isOptional()) .map(param->param.getParameterPath()) - .collect(toList()); + .toList(); this.optionalParameters = params.stream() .filter(param->param.isOptional()) .map(param->param.getParameterPath()) - .collect(toList()); + .toList(); this.reportNode = reportNode; this.sparqlString = sparqlString; this.query = ShLib.parseQueryString(sparqlString); diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java index 6f8100874f5..8d2a39865e6 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java @@ -21,8 +21,6 @@ import static org.apache.jena.shacl.lib.ShLib.displayStr; import java.util.*; -import java.util.stream.Collectors; - import org.apache.jena.atlas.lib.NotImplemented; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; @@ -244,7 +242,7 @@ private static Constraint parseConstraint(Graph g, Node s, Node p, Node o, Map shapes(Graph g, Map parsed, Set traversed, List elts) { - return elts.stream().map(x->ShapesParser.parseShapeStep(traversed, parsed, g, x)).collect(Collectors.toList()); + return elts.stream().map(x->ShapesParser.parseShapeStep(traversed, parsed, g, x)).toList(); } private static Constraint parseQualifiedValueShape(Graph g, Node s, Node p, Node o, Map parsed, Set traversed) { @@ -304,6 +302,6 @@ private static List listString(Graph g, Node node) { if ( ! Util.isSimpleString(n) ) throw new ShaclParseException("Not a string "+displayStr(n)+" in list "+elts); return n.getLiteralLexicalForm(); - }).collect(Collectors.toList()); + }).toList(); } } diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Parameters.java b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Parameters.java index 06105ce85e6..337cc0613cd 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Parameters.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Parameters.java @@ -21,8 +21,6 @@ import static org.apache.jena.shacl.sys.C.TRUE; import java.util.List; -import java.util.stream.Collectors; - import org.apache.commons.collections4.MultiMapUtils; import org.apache.commons.collections4.MultiValuedMap; import org.apache.jena.graph.Graph; @@ -40,7 +38,7 @@ public class Parameters { List params = G.listSP(shapesGraph, sccNode, SHACL.parameter).stream() .map(pn->parseParameter(shapesGraph, sccNode, pn)) - .collect(Collectors.toList()); + .toList(); return params; } diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/validation/HandlerBasedValidationListener.java b/jena-shacl/src/main/java/org/apache/jena/shacl/validation/HandlerBasedValidationListener.java index 3311a5a1662..661c443f684 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/validation/HandlerBasedValidationListener.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/validation/HandlerBasedValidationListener.java @@ -193,7 +193,7 @@ public ClassHierarchyStrategy() { } private List> getHandlers(Map, List>> handlers, List> eventTypes) { - return eventTypes.stream().flatMap(t -> handlers.getOrDefault(t, List.of()).stream()).collect(Collectors.toList()); + return eventTypes.stream().flatMap(t -> handlers.getOrDefault(t, List.of()).stream()).toList(); } } diff --git a/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexTests.java b/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexTests.java index 187640534ca..a960e37df3e 100644 --- a/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexTests.java +++ b/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexTests.java @@ -19,8 +19,6 @@ package org.apache.jena.shex.runner; import java.util.*; -import java.util.stream.Collectors; - import org.apache.jena.arq.junit.manifest.Manifest; import org.apache.jena.arq.junit.manifest.ManifestEntry; import org.apache.jena.arq.junit.manifest.Prefix; @@ -308,7 +306,7 @@ public static List extractTraits(ManifestEntry entry) { if (traitsRsrc == null) return null; List x = entry.getEntry().listProperties(ShexT.trait).toList(); - return x.stream().map(t -> t.getObject().asResource()).collect(Collectors.toList()); + return x.stream().map(t -> t.getObject().asResource()).toList(); } private static boolean runTestExclusionsInclusions(ManifestEntry entry) { @@ -328,7 +326,7 @@ private static boolean runTestExclusionsInclusions(ManifestEntry entry) { List traits = extractTraits(entry); if (traits != null) { - List excludedBecause = traits.stream().filter(excl -> excludeTraits.contains(excl)).collect(Collectors.toList()); + List excludedBecause = traits.stream().filter(excl -> excludeTraits.contains(excl)).toList(); if (excludedBecause.size() > 0) return false; } diff --git a/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexValidationTest.java b/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexValidationTest.java index fd69815545d..6bb95ba98a3 100644 --- a/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexValidationTest.java +++ b/jena-shex/src/test/java/org/apache/jena/shex/runner/ShexValidationTest.java @@ -23,8 +23,6 @@ import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; - import org.apache.jena.arq.junit.manifest.ManifestEntry; import org.apache.jena.atlas.io.IO; import org.apache.jena.atlas.lib.IRILib; @@ -155,7 +153,7 @@ public void run() { } if (this.extensionResults != null) { List output = semActPlugin.getOut(); - assertEquals(String.format("expected %s lines from SemAct, got %s", String.join("\n", extensionResults.stream().map(p -> p.getRight()).collect(Collectors.toList())), String.join("\n", output)), output.size(), extensionResults.size()); + assertEquals(String.format("expected %s lines from SemAct, got %s", String.join("\n", extensionResults.stream().map(p -> p.getRight()).toList()), String.join("\n", output)), output.size(), extensionResults.size()); for(int i = 0; i < extensionResults.size(); i++) { String expected = extensionResults.get(i).getRight(); String actual = output.get(i);