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

Implement OptionalCollector #87

Open
amaembo opened this issue Mar 17, 2016 · 2 comments
Open

Implement OptionalCollector #87

amaembo opened this issue Mar 17, 2016 · 2 comments

Comments

@amaembo
Copy link
Owner

amaembo commented Mar 17, 2016

OptionalCollector is the collector specialization which return type is Optional<R> and it has methods which mimic the optional behavior (like orElse, orElseGet, get, map, filter, etc.). Should support both short-circuiting and non-short-circuiting collection.

@ThomasBlt
Copy link

@amaembo Isn't that solved by MoreCollectors.onlyOne / findFirst() / findAny() ?

@amaembo
Copy link
Owner Author

amaembo commented Apr 22, 2020

No, the idea was to create a separate public type OptionalCollector, so you can do something like MoreCollectors.onlyOne().orElse("foo") as a shortcut to Collectors.collectingAndThen(MoreCollectors.onlyOne(), opt -> opt.orElse("foo")). Not sure whether it worth the effort though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants