java - Spring, beans and enum's valueOf -


when calling spring's "validate" eclipse, lot of errors when want enum using enum's implicit "valueof" method.

for example:

<bean id="docfamily" class="...docfamily" factory-method="valueof">     <constructor-arg>       <value>logy</value>     </constructor-arg> </bean> 

has eclipse telling me:

non-static factory method 'valueof' 1 arguments not found in factory bean class ...

however understand documentation:

beanwrapperimpl supports jdk 1.5 enums , old-style enum classes: string values treated enum value names

so above should work right? (btw 'constructor-arg' correct tag in case, shouldn't 'method-arg'?).

why eclipse/spring's "validate" giving me error message?

enum.valueof() has 2 arguments:

public static <t extends enum<t>> t valueof(class<t> enumtype, string name) 

therefore desired definition may this:

<bean id="docfamily" class="java.lang.enum" factory-method="valueof">      <constructor-arg index = "0"><value>...docfamily</value></constructor-arg>      <constructor-arg index = "1"><value>logy</value></constructor-arg> </bean>  

however, can more elegant solution:

<util:constant id = "docfamily" static-field = "...docfamily.logy" /> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -