Created
January 10, 2014 17:23
-
-
Save edeustace/8358527 to your computer and use it in GitHub Desktop.
Java -> scala conversion of nested types
This file contains hidden or 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
package org.corespring | |
import org.specs2.mutable.Specification | |
import scala.collection._ | |
class JavaConversionsSpec extends Specification { | |
import scala.collection.JavaConversions._ | |
def contributors : java.util.Map[String, java.util.Collection[String]] = new java.util.HashMap[String,java.util.Collection[String]]() | |
def convert(input:mutable.Map[String,Seq[String]]):String= "{}" | |
implicit def converter(in : java.util.Map[String, java.util.Collection[String]]) : mutable.Map[String,Seq[String]] = { | |
mapAsScalaMap(in).map( (kv) => kv._1 -> collectionAsScalaIterable(kv._2).toSeq) | |
} | |
"JavaConversions" should { | |
"make it possible to call convert with a java structure" in { | |
convert(contributors) === "{}" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment