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

GROOVY-9337: add extension methods for Optional, OptionalInt, et al. #1136

Merged
merged 2 commits into from Jan 10, 2020

Conversation

eric-milles
Copy link
Member

https://issues.apache.org/jira/browse/GROOVY-9337

Adds:

  • get() to OptionalInt, OptionalLong, OptionalDouble
  • filter(Class) to Optional
  • filter([Int|Long|Double]Predicate) to OptionalInt, OptionalLong, OptionalDouble
  • mapToObj([Int|Long|Double]Function) to OptionalInt, OptionalLong, OptionalDouble
  • mapToInt(ToIntFunction) to Optional
  • mapToLong(ToLongFunction) to Optional
  • mapToDouble(ToDoubleFunction) to Optional
  • stream() to Optional -- exists as normal method since Java 9

No stream() yet for OptionalInt, OptionalLong, OptionalDouble because it is unclear if return should be Stream or IntStream. Looking into DGSMs IntStream.of(OptionalInt) and Stream.of(OptionalInt) to support both options. Also, as with Optional#stream, OptionalInt, etc. have a stream() method since Java 9.

There are some additional items mentioned in GROOVY-9337; I haven't completed research for them yet.

@daniellansun
Copy link
Contributor

+0
I'm not sure whether we should add new features to 3.0.0 at this moment as 3.0.0 GA will be out very soon.

Iterator, Spliterator, Enumeration and Optional[Int|Long|Double]
@daniellansun daniellansun merged commit 0ab73e7 into master Jan 10, 2020
@daniellansun
Copy link
Contributor

As nobody rejects the PR in the past 72 hours, merged. Thanks.

@eric-milles eric-milles deleted the GROOVY-9337 branch February 11, 2020 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants