Created
March 1, 2015 15:50
-
-
Save frgomes/b70ab4aa5f7359831d3c to your computer and use it in GitHub Desktop.
Scala - Convert java.util.Properties to Map[String, Option[Map]]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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