mardi 6 juin 2017

scala reflection get class of enumaration value

Assume we have

class User(val name: String, val role: UserRole.Value)

class UserRole extends Enumeration {
    val Admin, User = Value
}

val u = new User("root", UserRole.Admin)

how to get Class[_] "class UserRole" when

u.role.getClass

return "scala.Enumeration.Value"





Aucun commentaire:

Enregistrer un commentaire