Created
April 16, 2015 19:00
-
-
Save mrnovalles/71d3a3070fe00ca4caae to your computer and use it in GitHub Desktop.
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
def caseClassToParams(cc: Product) = { | |
val fields = cc.getClass.getDeclaredFields.map(_.getName) | |
val keyValues = fields.zip(cc.productIterator.to).toList | |
keyValues.flatMap { | |
case ("foo", v) => { | |
val values = v.toString.split("&").toList | |
values.map{ p => | |
val pair = p.split("=") | |
(pair.head, pair.last) | |
} | |
} | |
case (k, v) => List((k, v.toString)) | |
}.toMap | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment