Skip to content
Browse files

use appropriate case class constructor

  • Loading branch information...
1 parent b0c4a02 commit 9e01ff3e164533a59aa71476387ffe81cf132e30 @wg committed Apr 23, 2012
Showing with 11 additions and 5 deletions.
  1. +1 −1 README
  2. +1 −1 project/build/project.scala
  3. +9 −3 src/main/scala/jacks/module.scala
View
2 README
@@ -4,7 +4,7 @@ jacks - Jackson module for Scala
types, including mutable & immutable collections, Option, Tuple, Symbol,
and case classes.
- This version of jacks has been tested against Scala 2.9.2 and Jackson 2.0.0
+ This version of jacks has been tested against Scala 2.9.2 and Jackson 2.0.1
Join the lambdaWorks-OSS Google Group to discuss this project:
View
2 project/build/project.scala
@@ -2,7 +2,7 @@ import sbt._
class project(info: ProjectInfo) extends DefaultProject(info) {
override def libraryDependencies = Set(
- "com.fasterxml.jackson.core" % "jackson-databind" % "2.0.0",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.0.1",
"org.scala-lang" % "scalap" % crossScalaVersionString,
"org.scalatest" %% "scalatest" % "1.6.1" % "test",
View
12 src/main/scala/jacks/module.scala
@@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.deser._
import com.fasterxml.jackson.databind.ser._
import com.fasterxml.jackson.databind.`type`._
-import java.lang.reflect.Method
+import java.lang.reflect.{Constructor, Method}
import tools.scalap.scalax.rules.scalasig.ScalaSig
@@ -146,7 +146,12 @@ class ScalaTypeSig(val tf: TypeFactory, val `type`: JavaType, val sig: ScalaSig)
val cls = sig.topLevelClasses.head.asInstanceOf[ClassSymbol]
def isCaseClass = cls.isCase
- def constructor = `type`.getRawClass.getDeclaredConstructors.head
+ def constructor: Constructor[_] = {
+ val types = accessors.map(_.`type`.getRawClass)
+ `type`.getRawClass.getDeclaredConstructors.find {
+ _.getParameterTypes.zip(types).forall { case (a, b) => a.isAssignableFrom(b) }
+ }.get
+ }
def accessors: Array[Accessor] = {
var list = collection.mutable.ListBuffer[Accessor]()
@@ -189,6 +194,7 @@ class ScalaTypeSig(val tf: TypeFactory, val `type`: JavaType, val sig: ScalaSig)
object ScalaTypeSig {
import tools.scalap.scalax.rules.scalasig.{ScalaSigParser, Symbol}
+ import scala.collection.immutable._
def apply(tf: TypeFactory, t: JavaType): Option[ScalaTypeSig] = {
ScalaSigParser.parse(t.getRawClass) match {
@@ -197,7 +203,7 @@ object ScalaTypeSig {
}
}
- val types = immutable.Map[String, Class[_]](
+ val types = Map[String, Class[_]](
"scala.Boolean" -> classOf[Boolean],
"scala.Byte" -> classOf[Byte],
"scala.Char" -> classOf[Char],

0 comments on commit 9e01ff3

Please sign in to comment.
Something went wrong with that request. Please try again.