Grails

Getting property class from property name

Recently in one of my project i had a requirement of identifying the class of a property of an object with object class and property name and then determining whether it's an Enum class or not. I found an easy solution for this using Reflection API. Using Java Reflection you can inspect the fields (member variables) of classes. This is...

by Sachin Verma
Tag: enum
26-Sep-2012

Grails

Groovy: Few ways to convert string into enum

Many at times, we have a string which needs to be converted into Enum. I will be sharing few options as stated by Mr.Haki, Isa Goksu and in the last the one I discovered during the process. Lets say we have a Enum AccountType as given below : [groovy] enum AccountType { CHECKING, SAVING } assert AccountType.CHECKING...

by Amit Jain
Tag: enum
15-Apr-2011