|
Re: Dynamic Moxy accessing enum values [message #657939 is a reply to message #657607] |
Fri, 04 March 2011 16:57 |
|
I am posting the following on behalf of Rick Barkhouse, who originally answered this question on Stack Overflow ( http://stackoverflow.com/questions/5181374/eclipselink-dynam ic-moxy-accessing-enum-values/5183847#5183847):
---
Hi Micha,
To use an enum value for a set() operation, you need to first look up the enum constant using DynamicJAXBContext.getEnumConstant(), and then use that for the set. For example:
Object NORTH = ctx.getEnumConstant("your.package.CompassDirection", "NORTH");
person.set("quadrant", NORTH);
To get the value, you are calling the correct code, but the value that comes back will not be a String, it will the actual enum value Object associated with that String. You should use:
Object quadrant = person.get("quadrant");
Hope this helps,
Rick
|
|
|
Powered by
FUDForum. Page generated in 0.03306 seconds