I've got a list of case objects of the same type, eg.
object Countries {
sealed abstract class Country (val name: String)
case object SE extends Country("Sweden")
case object AE extends Country("United Arab Emirates")
case object GB extends Country("United Kingdom")
case object US extends Country("United States of America")
}
Now I want to create a mapping like this.
val map = Map[String, Country](
CH.name -> CH,
AE.name -> AE,
GB.name -> GB,
US.name -> US
)
So that I can do this ie. get a reference to the appropriate case object by passing it's String key.
val us = Countries.map.get("United Kingdom")
Is there a way to automatically generate the map
?