v1.4.0
This release includes some changes to the common indexer, as well as some changes to org.allenai.common.Enum
.
Migrating from 1.3.0
There are two ways to migrate: Serialization-compatible (where the JSON generated is identical), and serialization-non-compatible (where the JSON serialized changes, but you have to make fewer changes).
v1.3.0 code:
sealed abstract class MyEnum(id: String) extends Enum[MyEnum](id)
object MyEnum extends EnumCompanion[MyEnum] {
case object One extends MyEnum("one")
case object Two extends MyEnum("two")
register(One, Two)
}
If you wish to be fully backwards-compatible (with One
serializing as the JSON string "one"
), you should update your code to the following:
// Note the `override val` before `id`.
sealed abstract class MyEnum(override val id: String) extends Enum[MyEnum]
object MyEnum extends EnumCompanion[MyEnum] {
// Creation / registration code remains identical.
case object One extends MyEnum("one")
case object Two extends MyEnum("two")
register(One, Two)
}
If you're OK with your enums serializing with new text matching the case object names (One
serializing as the JSON string "One"
), you should update your code to the following:
// No constructor parameters.
sealed abstract class MyEnum extends Enum[MyEnum]
object MyEnum extends EnumCompanion[MyEnum] {
case object One extends MyEnum
case object Two extends MyEnum
register(One, Two)
}