laeubi commented on code in PR #913:
URL: https://github.com/apache/maven/pull/913#discussion_r1081279805


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java:
##########
@@ -28,4 +29,20 @@
 public interface MavenWorkspaceReader extends WorkspaceReader {
 
     Model findModel(Artifact artifact);
+
+    /**
+     * List all available artifacts this workspace repository manages.
+     *
+     * @return a stream of artifacts in no particular order
+     * @since 3.9.0
+     */
+    Stream<Artifact> listArtifacts();

Review Comment:
   Well that's all a bit hypothetical.... if you are certain you can always 
wrap streams in try-with-resource... 
   Streams are much better suited than collections, as the caller can filter 
them or convert them to any type they need without having to think about if the 
collection could be modified or not.
   
   Streams also the the advantage that they are _lazy_ if I search for an item 
(using `findFirst()` / `findAny()` / `anyMatch()`) only those items are 
evaluated up to the point where a match is found in contrast to a collection 
that is _greedy_ and thus requires to evaluate all content even if the first 
item is what I want.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to