pjfanning / jackson-module-enumeratum

Enumeratum support for Jackson
Apache License 2.0
4 stars 3 forks source link

Improve EnumeratumDeserializer reflection tricks #1

Closed jtjeferreira closed 3 years ago

jtjeferreira commented 3 years ago

I found your project on github and tried it on my project but was having issues with nested enums like this:

object Ctx {
  sealed abstract class Color(override val entryName: String) extends EnumEntry

  object Color extends Enum[Color] {

    val values = findValues

    case object Red extends Color("red")
    case object Green extends Color("green")
    case object Blue extends Color("blue")
  }
}

I got inspiration for this way of reflection from https://github.com/FasterXML/jackson-module-scala/blob/a6576f789381fd5ba876c15f9a8ca8db35104f7a/src/main/scala/com/fasterxml/jackson/module/scala/deser/EnumerationDeserializerModule.scala#L36

pjfanning commented 3 years ago

thanks @jtjeferreira -- would it be possible for you to add a test case based on the Ctx object and nested Color object in your example?

pjfanning commented 3 years ago

I added some tests based on your test object: Ctx

jtjeferreira commented 3 years ago

I added some tests based on your test object: Ctx

Thx, I was planning to do that over the weekend