-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Replace play.libs.F.Option
with Java 8 equivalent
#4692
Conversation
Here is what I have changed:
@dotta there is a problem with the |
case x: play.libs.F.None[_] => None | ||
/** Transforms a Play Java `Optional` to a proper Scala `Option`. */ | ||
implicit def javaOptionToScala[T](x: Optional[T]): Option[T] = { | ||
if (x.isPresent) Some(x.get) else None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use the scala-java8-compat
library for these kind of conversions? See here.
@marcospereira Great job Marcos! |
@dotta I've change the PR to use scala-java8-compat. Thanks for pointing that. Anyway, I could not figure out why |
@marcospereira LGTM! Later today I'll see if I can find some time to look into the |
Ok. I debug the code and figure out the problem now.
And this method was being called here: This is now fixed and the build should be green. |
Rebased. |
1. Code documentation was also updated to remove mentions about F.Option and subclasses of it. 2. The Some class, which was a subclass of F.Option did not complain about null values. Because of that, Optional.ofNullable was used to guarantee the same behavior. 3. Some other small changes were made to cleanup the code, following the boy scout rule defined in contribution guidelines.
Replace `play.libs.F.Option` with Java 8 equivalent
@@ -234,7 +234,7 @@ object PlayBuild extends Build { | |||
.enablePlugins(SbtTwirl) | |||
.settings( | |||
addScalaModules(scalaParserCombinators), | |||
libraryDependencies ++= runtime(scalaVersion.value) ++ scalacheckDependencies, | |||
libraryDependencies ++= runtime(scalaVersion.value) ++ scalacheckDependencies ++ Seq(scalaJava8Compat), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minor nitpick, but you could use :+
(append) instead of ++
and wrapping the dependencies in a Seq
. No need to change this, but I'm pointing it out just in case you didn't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not. Thanks. :-)
@marcospereira How did you fix it? I can't easily see what is that was changed to fix it. |
@dotta mostly debugging the code and reading Spring docs. Here is the line that did the trick: Before this commit, it was using |
Got it, thanks! (Wow, that must have been a tricky one to nail down ;-)) |
Replace
play.libs.F.Option
and friends withjava.util.Optional
and friends