Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
use appropriate case class constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
wg committed Apr 25, 2012
1 parent b0c4a02 commit 9e01ff3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jacks - Jackson module for Scala
types, including mutable & immutable collections, Option, Tuple, Symbol, types, including mutable & immutable collections, Option, Tuple, Symbol,
and case classes. 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: Join the lambdaWorks-OSS Google Group to discuss this project:


Expand Down
2 changes: 1 addition & 1 deletion project/build/project.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._


class project(info: ProjectInfo) extends DefaultProject(info) { class project(info: ProjectInfo) extends DefaultProject(info) {
override def libraryDependencies = Set( 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.scala-lang" % "scalap" % crossScalaVersionString,


"org.scalatest" %% "scalatest" % "1.6.1" % "test", "org.scalatest" %% "scalatest" % "1.6.1" % "test",
Expand Down
12 changes: 9 additions & 3 deletions src/main/scala/jacks/module.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.deser._
import com.fasterxml.jackson.databind.ser._ import com.fasterxml.jackson.databind.ser._
import com.fasterxml.jackson.databind.`type`._ import com.fasterxml.jackson.databind.`type`._


import java.lang.reflect.Method import java.lang.reflect.{Constructor, Method}


import tools.scalap.scalax.rules.scalasig.ScalaSig import tools.scalap.scalax.rules.scalasig.ScalaSig


Expand Down Expand Up @@ -146,7 +146,12 @@ class ScalaTypeSig(val tf: TypeFactory, val `type`: JavaType, val sig: ScalaSig)
val cls = sig.topLevelClasses.head.asInstanceOf[ClassSymbol] val cls = sig.topLevelClasses.head.asInstanceOf[ClassSymbol]


def isCaseClass = cls.isCase 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] = { def accessors: Array[Accessor] = {
var list = collection.mutable.ListBuffer[Accessor]() var list = collection.mutable.ListBuffer[Accessor]()
Expand Down Expand Up @@ -189,6 +194,7 @@ class ScalaTypeSig(val tf: TypeFactory, val `type`: JavaType, val sig: ScalaSig)


object ScalaTypeSig { object ScalaTypeSig {
import tools.scalap.scalax.rules.scalasig.{ScalaSigParser, Symbol} import tools.scalap.scalax.rules.scalasig.{ScalaSigParser, Symbol}
import scala.collection.immutable._


def apply(tf: TypeFactory, t: JavaType): Option[ScalaTypeSig] = { def apply(tf: TypeFactory, t: JavaType): Option[ScalaTypeSig] = {
ScalaSigParser.parse(t.getRawClass) match { ScalaSigParser.parse(t.getRawClass) match {
Expand All @@ -197,7 +203,7 @@ object ScalaTypeSig {
} }
} }


val types = immutable.Map[String, Class[_]]( val types = Map[String, Class[_]](
"scala.Boolean" -> classOf[Boolean], "scala.Boolean" -> classOf[Boolean],
"scala.Byte" -> classOf[Byte], "scala.Byte" -> classOf[Byte],
"scala.Char" -> classOf[Char], "scala.Char" -> classOf[Char],
Expand Down

0 comments on commit 9e01ff3

Please sign in to comment.