Last month we were coding some Groovy stuff and we needed to use Enum equivalents of couple Strings. We had couple dynamic Strings coming from off-shore developers, which defines the type of the entity. In our system, those types were represented by Enums. Anyways, basically we had to resolve the Enums from given Strings. After a little reading, we came up with following solution:
enum Colors {
BLUE,
WHITE
}
// ..
Colors blue = Enum.valueOf(Colors.class, "BLUE");
BLUE,
WHITE
}
// ..
Colors blue = Enum.valueOf(Colors.class, "BLUE");
I thought I should post a blog entry about this :)









