Skip to content

Function Converters #48

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

Merged
merged 2 commits into from
Jul 28, 2015
Merged

Function Converters #48

merged 2 commits into from
Jul 28, 2015

Conversation

retronym
Copy link
Member

Rebase of #39

Ichoran added 2 commits July 28, 2015 16:58
…from Jason Zaugg.

If you have something from java.util.functions, you should be able to

```
import scala.compat.java8.FunctionConverters._
```

and then use `.asScala` to convert to the corresponding Scala function.

If you have a Scala function, use `.asJava` to convert to the best-matching item from java.util.functions.
If you want a function that isn't the best match, use the corresponding `asJavaInterfaceName` method, e.g.

```
asJavaUnaryOperator((i: Int) => i+1)   // Best match would be IntUnaryOperator

The code is created with a code generator that needs to run in Scala 2.11+,
but SBT runs 2.10 by default.  Thus, build.sbtt was reworked to be
multi-module (the sub-module is the code generator).
These were written manually to avoid making the same assumptions in code
generation for the converters and the tests, and thereby missing important
bugs.  As a downside, though, they do not have complete code coverage.  This
should not matter given how the code generator works, but it is a weak point.
@retronym retronym modified the milestone: 0.5.0 Jul 28, 2015
@retronym
Copy link
Member Author

LGTM, sorry for the slow review, and thanks for writing all those tests!

retronym added a commit that referenced this pull request Jul 28, 2015
@retronym retronym merged commit 31244ba into scala:master Jul 28, 2015
@retronym retronym modified the milestones: 0.6.0, 0.5.0 Aug 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants