Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ object BeanIntrospector {
//create properties for all appropriate fields
val fields = for {
cls <- hierarchy
classW = ClassW(cls)
field <- cls.getDeclaredFields
name = maybePrivateName(field)
if !name.contains('$')
if (isScalaCaseObject(cls) || isAcceptableField(field))
if (classW.isScalaObject || isScalaCaseObject(cls) || isAcceptableField(field))
beanGetter = findBeanGetter(cls, name)
beanSetter = findBeanSetter(cls, name)
} yield PropertyDescriptor(name, findConstructorParam(hierarchy.head, name), Some(field), findGetter(cls, name), findSetter(cls, name), beanGetter, beanSetter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object ScalaAnnotationIntrospector extends NopAnnotationIntrospector with ValueI
private [this] val _descriptorCache = new LRUMap[ClassKey, BeanDescriptor](16, 100)

private def _descriptorFor(clz: Class[_]): Option[BeanDescriptor] = {
if (clz.hasSignature || clz.extendsScalaClass) {
if (clz.extendsScalaClass || clz.hasSignature) {
val key = new ClassKey(clz)
Option(_descriptorCache.get(key)) match {
case Some(result) => Some(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package com.fasterxml.jackson.module.scala.util

import scala.language.implicitConversions
import scala.reflect.{ScalaLongSignature, ScalaSignature}
import scala.util.Try

trait ClassW extends PimpedType[Class[_]] {

def extendsScalaClass: Boolean = {
ClassW.productClass.isAssignableFrom(value)
ClassW.productClass.isAssignableFrom(value) || isScalaObject
}

def hasSignature: Boolean = {
Expand All @@ -19,6 +20,10 @@ trait ClassW extends PimpedType[Class[_]] {
}
hasSigHelper(value)
}

def isScalaObject: Boolean = {
Try(value.getField("MODULE$")).isSuccess
}
}

object ClassW {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ObjectSerializerTest extends SerializerTest {
import ObjectSerializerTest._
def module = DefaultScalaModule

"An ObjectMapper with the DefaultScalaModule" should "serialize an object as a bean" ignore {
"An ObjectMapper with the DefaultScalaModule" should "serialize an object as a bean" in {
serialize(ObjectWithoutJsonProperty) should (
equal ("""{"name":"name1","value":"value1"}""") or
equal ("""{"value":"value1","name":"name1"}""")
Expand Down