Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new method IQueryResult.stream() #312

Merged
merged 2 commits into from
Sep 11, 2023

Conversation

HannesWell
Copy link
Member

This improves the interoperability of IQueryResult and the Java's modern Stream-API.

Additionally Clean-up IQueryResult and its implementations in a separate first commit.

@@ -8,4 +8,12 @@
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/equinox/p2/query/IQueryResult.java" type="org.eclipse.equinox.p2.query.IQueryResult">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IQueryResult is not marked with @noimplement/@noextend but I wonder if clients are really supposed to create own implementations?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tycho has some implementations of IQueryResult, I don't see why one should not allow this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People do what they're not supposed to do, so if they're allowed, one can assume that someone will to it. 😱

What about a default method that does toSet().stream() so that by default there is always an implementation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK with custom queryable this makes sense.
Tycho even already has a stream() method in its own implementation, but it only needs to be made public when depending on the next Eclipse Release, so I think this is fine.
https://github.com/eclipse-tycho/tycho/blob/master/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/ListQueryable.java#L80-L83

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IQueryable already implements Iterable so using the iterator for default implementations seems a better choice to prevent creation of an intermediate set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a default method that does toSet().stream() so that by default there is always an implementation?

That's possible. But as Christoph suggested it could use the Spliterator of the IQueryResult, like it is currently done in QueryResult.

Iterable itself unfortunately does not provide a stream() method (if it would this PR would be pointless).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a default method that does toSet().stream() so that by default there is always an implementation?

That's possible. But as Christoph suggested it could use the Spliterator of the IQueryResult, like it is currently done in QueryResult.

Done.

Copy link
Contributor

@merks merks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@github-actions
Copy link

github-actions bot commented Sep 2, 2023

Test Results

       9 files  ±0         9 suites  ±0   35m 44s ⏱️ - 2m 22s
2 175 tests ±0  2 171 ✔️ +1    4 💤 ±0  0 ±0 
6 615 runs  ±0  6 604 ✔️ +1  11 💤 ±0  0 ±0 

Results for commit a55a707. ± Comparison against base commit fb0c40c.

♻️ This comment has been updated with latest results.

This improves the interoperability of IQueryResult and Java's
Stream-API.
@HannesWell HannesWell merged commit 5bf07ad into eclipse-equinox:master Sep 11, 2023
6 checks passed
@HannesWell HannesWell deleted the queryResultStream branch September 11, 2023 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants