How to access objects within an object by mixing in a trait with reflection?
问题 How can I get all of the objects within an object with reflection? Consider this code: object MonthDay extends MyEnum { //Some important holidays object NewYear extends MonthDay( 1, 1) object UnityDay extends MonthDay(11, 9) object SaintNicholas extends MonthDay(12, 6) object Christmas extends MonthDay(12, 24) } class MonthDay(month: Int, day: Int) trait MyEnum { val values: List[MonthDay] = this.getClass.getField("MODULE$")... val next: MonthDay = ... val previous: MonthDay = ... } //Of