mercredi 17 août 2016

how to reflect enumation class in scala?

I have scala enumation I want to get the enumation value from String.

object CVVStatus extends Enumeration{
type CVVStatus = Value
val PRESENT, NOT_PRESENT, VALID, INVALID = Value
}

I want to do like:

val prop = new Properties()
prop.load(new FileInputStream("config.conf"))
val tmp = prop.getProperty(propname)
val s:CVVStatus = StringtoEmum(tmp)

If I need lots of enumeration from different enumeration object name to enumeration objects. How should I do it? what package I should import?





Aucun commentaire:

Enregistrer un commentaire