Skip to content

Commit 262ba80

Browse files
committed
Update BeanIntrospector.scala
1 parent 4ffced2 commit 262ba80

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/scala/com/fasterxml/jackson/module/scala/introspect/BeanIntrospector.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,12 @@ object BeanIntrospector {
192192
//create properties for all appropriate fields
193193
val fields = for {
194194
cls <- hierarchy
195-
classW = ClassW(cls)
195+
scalaCaseObject = isScalaCaseObject(cls)
196+
isScalaObject = ClassW(cls).isScalaObject
196197
field <- cls.getDeclaredFields
197198
name = maybePrivateName(field)
198199
if !name.contains('$')
199-
if (classW.isScalaObject || isScalaCaseObject(cls) || isAcceptableField(field))
200+
if (isScalaObject || scalaCaseObject || isAcceptableField(field))
200201
beanGetter = findBeanGetter(cls, name)
201202
beanSetter = findBeanSetter(cls, name)
202203
} yield PropertyDescriptor(name, findConstructorParam(hierarchy.head, name), Some(field), findGetter(cls, name), findSetter(cls, name), beanGetter, beanSetter)
@@ -206,7 +207,7 @@ object BeanIntrospector {
206207
//We also require that there is no field defined on the class matching the param name -
207208
//the assumption is that if we have made it this far, the field/getter/setter combo would have been
208209
//picked up if the field was valid. If we have not already added the field, and it's present, then
209-
//it must be somehow inappropriate (static, volitile, etc)
210+
//it must be somehow inappropriate (static, volatile, etc)
210211
//this catches the case where people explicitly write getter-like and setter-like methods
211212
//(for example, compound properties)
212213
//Note - this will discard 'dangling' getters as an introspected property - getters must have setters,
@@ -220,8 +221,8 @@ object BeanIntrospector {
220221
if findField(cls, name).isEmpty
221222
if !name.contains('$')
222223
if !fields.exists(_.name == name)
223-
getterProperty = getter.getAnnotation(classOf[JsonProperty])
224-
setter = findSetter(cls, name) if setter.isDefined || (getterProperty != null && getterProperty.value != JsonProperty.USE_DEFAULT_NAME)
224+
getterProperty = Option(getter.getAnnotation(classOf[JsonProperty]))
225+
setter = findSetter(cls, name) if setter.isDefined || (getterProperty.isDefined && getterProperty.get.value != JsonProperty.USE_DEFAULT_NAME)
225226
beanGetter = findBeanGetter(cls, name)
226227
beanSetter = findBeanSetter(cls, name)
227228
} yield PropertyDescriptor(name, None, None, Some(getter), setter, beanGetter, beanSetter)

0 commit comments

Comments
 (0)