Shamik Shamik - 9 months ago 53
Java Question

How to use Spring to get the value of an Enum

<bean id="xyz" class="" >
<property name="name">
<property name="staticField" value="" />

This is the way previously I used to set the name of class Now, the names should come from another enum. How do I access the enum value to set the name property of my class

Answer Source

I don't see why you can't keep on using FieldRetrievingFactoryBean, that's what it's for.

It's a little bit easier to use than your example suggests, though. Also, there's the easier schema-based syntax which does the same thing, <util:constant>.

Both approaches are documented (and compared) here.

(Remember that enum values are just static fields on the enum class)