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 example for Java 8 Streams via default method. #60

Closed
thomasdarimont opened this issue Mar 9, 2015 · 4 comments
Closed

Add example for Java 8 Streams via default method. #60

thomasdarimont opened this issue Mar 9, 2015 · 4 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@thomasdarimont
Copy link
Contributor

We should show how to use Java 8 Streams in a default method by delegating to another finder and calling stream() on the result.

thomasdarimont pushed a commit that referenced this issue Mar 9, 2015
Outlines the use of Stream as simple wrapper around actual finder method result with a default method.
@odrotbohm
Copy link
Member

Is that example really something we'd recommend people to do? Turning a List into a Stream i a default method replaces a single method call on the List with an additional method declaration on the repository. Also, it doesn't really create any of the benefits you'd usually get when declaring a Stream method on the repository (actually streaming the results).

@thomasdarimont
Copy link
Contributor Author

I just wanted to highlight two different ways to use Java 8 Streams - the variant with the default method simply shows how easy it is to extend the existing API without having to call stream() on the result yourself - this makes for shorter examples and demonstrates another use of default methods.

@odrotbohm
Copy link
Member

To me it looks more like a "because you can" rather than something really useful. Would you really add three more lines and an additional repository method instead of just calling ….stream() on the client? Especially if it doesn't really give you a Stream but only a streaming view of the list? Why not declare an additional, really streaming method? You write less code and actually get the benefits of the new return type. IYAM, what we have in #62 is short, concise and practical.

@mp911de
Copy link
Member

mp911de commented Jun 16, 2020

Since we have native Stream support, this issue is no longer valid.

@mp911de mp911de closed this as completed Jun 16, 2020
@mp911de mp911de added status: invalid An issue that we don't feel is valid status: declined A suggestion or change that we don't feel we should currently apply and removed status: invalid An issue that we don't feel is valid labels Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants