Skip to content

Instantly share code, notes, and snippets.

@frgomes
Created March 1, 2015 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frgomes/b70ab4aa5f7359831d3c to your computer and use it in GitHub Desktop.
Save frgomes/b70ab4aa5f7359831d3c to your computer and use it in GitHub Desktop.
Scala - Convert java.util.Properties to Map[String, Option[Map]]
object PropertyConverters extends PropertyConverters
trait PropertyConverters {
import java.util.Properties
implicit class RichOptionString2File(props: Properties) {
implicit def asMap: Map[String, Option[Any]] =
(Map[String, Option[Any]]() /: props.keySet.toArray) {
(acc, key) =>
acc + (key.toString -> Option(props.get(key)))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment