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

API design improvement proposal: overload all methods #19

Open
mleg opened this issue Mar 24, 2022 · 2 comments
Open

API design improvement proposal: overload all methods #19

mleg opened this issue Mar 24, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@mleg
Copy link

mleg commented Mar 24, 2022

Found annoying to figure out each time which method to use. I'm not very good at rememebering all Java functional interfaces.

Proposal:

Give all Sneaky class methods same name (unchecked for example) thus overloading them.
Instead of writing

myStream.forEach(Sneaky.consumer(lambda));

it would look like

myStream.forEach(unchecked(lambda));

Notice static import now is more sensible.
Also it helps with refactoring when lambda signature changes.

@SimonHarmonicMinor
Copy link
Owner

@mleg Sounds like a good idea! Pull requests are welcome

@SimonHarmonicMinor
Copy link
Owner

@mleg By the way, I don't think that you should rename all methods in Sneaky class. But instead there has to be a separate unchecked method with required overloaded parameters. Because sometimes we do need to create particular functional wrapper.

var supplier = Sneaky.supplier(() -> 1);

@SimonHarmonicMinor SimonHarmonicMinor added the enhancement New feature or request label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants