abstract case class MyEnum(id: Int) object MyEnum { object Foo extends MyEnum(0) object Bar extends MyEnum(1) object Baz extends MyEnum(2) }