Would any one please shed a light.
how to convert a String like:
String colorStr = "Red";
to an Object Color.red
edit: Thought I should mention that the class is abstract to force instances to be named or anonymous subclasses, which makes it possible to obtain the ParameterizedType from the genericSuperclass.
Rob Spoor wrote:Your class is missing the following three methods:
The first two are required as per the contract of java.util.Map.
Thanks Rob, for pointing that out. I'll keep that in mind if I ever publish the class.
Rob Spoor wrote:I actually don't like this trick. Instead of an entire class I'd use one static utility method instead:
I actually had this approach too, and the code is very similar to yours (but yours is more complete in that it checks the modifiers)I didn't think of using Class#cast(...) instead of suppressing the warning.