UniJ icon indicating copy to clipboard operation
UniJ copied to clipboard

Support Duration and Optional

Open astubbs opened this issue 5 years ago • 2 comments

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

astubbs avatar Aug 12 '20 11:08 astubbs

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:

  1. they are non-trivial (unlike e.g. Optional.isEmpty or Duration.toSeconds),
  2. 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?

tlinkowski avatar Aug 14 '20 11:08 tlinkowski

Thanks for the thoughtful response! No I wasn’t - thanks :)

astubbs avatar Aug 14 '20 11:08 astubbs