Using type aliases to Java enums
- by oxbow_lakes
I would like to achieve something similar to how scala defines Map as both a predefined type and object. In Predef:
type Map[A, +B] = collection.immutable.Map[A, B]
val Map = collection.immutable.Map //object Map
However, I'd like to do this using Java enums (from a shared library). So for example, I'd have some global alias:
type Country = my.bespoke.enum.Country
val Country = my.bespok.enum.Country //compile error: "object Country is not a value"
The reason for this is that I'd like to be able to use code like:
if (city.getCountry == Country.UNITED_KINGDOM) //or...
if (city.getCountry == UNITED_KINGDOM)
Howver, this not possible whilst importing my type alias at the same time. Note: this code would work just fine if I had not declared a predefined type and imported it! Is there some syntax I can use here to achieve this?