UniJ
UniJ copied to clipboard
Support Duration and Optional
Just trying out your project - interesting idea. I immediately hit the missing Duration#toSeconds et al and Optional#isEmpty...
Do you have any policy on the scope of the project?
toSeconds was intro'd in 9 isEmpty was 11
Hi Antony, thanks!
The main policy is expressed in the notes:
UniJ may only introduce new APIs that directly correspond to APIs in the latest stable release of the JDK
So it's not completely out of question, but I took an approach of providing static facade methods for JDK instance methods only if:
- they are non-trivial (unlike e.g.
Optional.isEmptyorDuration.toSeconds), - and using static methods instead of instance methods wouldn't be cumbersome (unlike in case of e.g.
Stream.takeWhile)
I wouldn't like to clutter the library with features that few people might need (UniJ is already way to complex), especially if they're so easy to introduce on one's own (as you did). But if there were several requests for any method like that, I'd reconsider (I'll leave this issue open for that purpose).
PS. As to Duration.toSeconds - are you aware of its pre-JDK9 alias, Duration.getSeconds?
Thanks for the thoughtful response! No I wasn’t - thanks :)