Skip to content

Commit

Permalink
try to fix #218
Browse files Browse the repository at this point in the history
  • Loading branch information
PJ Fanning committed Jan 29, 2020
1 parent a59c56e commit fb345cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import com.fasterxml.jackson.module.paranamer.ParanamerAnnotationIntrospector
import com.fasterxml.jackson.module.scala.JacksonModule
import com.fasterxml.jackson.module.scala.util.Implicits._

object ScalaAnnotationIntrospector extends NopAnnotationIntrospector
{
object ScalaAnnotationIntrospector extends NopAnnotationIntrospector {
private [this] val _descriptorCache = new LRUMap[ClassKey, BeanDescriptor](16, 100)

private def _descriptorFor(clz: Class[_]): BeanDescriptor = {
Expand All @@ -32,7 +31,11 @@ object ScalaAnnotationIntrospector extends NopAnnotationIntrospector

private def methodName(am: AnnotatedMethod): Option[String] = {
val d = _descriptorFor(am.getDeclaringClass)
d.properties.find(p => (p.getter ++ p.setter).exists(_ == am.getAnnotated)).map(_.name)
val getterSetter = d.properties.find(p => (p.getter ++ p.setter).exists(_ == am.getAnnotated)).map(_.name)
getterSetter match {
case Some(s) => Some(s)
case _ => d.properties.find(p => p.name == am.getName).map(_.name)
}
}

private def paramName(ap: AnnotatedParameter): Option[String] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ class OverrideValSerializerTest extends SerializerTest {

"DefaultScalaModule" should "handle overrides in vals" in {
val id = UUID.randomUUID()
//TODO https://github.com/FasterXML/jackson-module-scala/issues/218
//the json should also include "id":"<idAsString>"
//https://github.com/FasterXML/jackson-module-scala/issues/218
val json = serialize(Sub(id, "something"))
//json should include (s""""id":"${id.toString}"""")
json should include (s""""id":"${id.toString}"""")
json should include (""""type":"baseclass"""")
json should include (""""something":"something"""")
}
Expand Down

0 comments on commit fb345cd

Please sign in to comment.