I have a class which constructor takes a Jakarta enums. I'm trying to find how I can easily inject it via an Spring XML aplicationContext.
For example :
The enum :
public class MyEnum extends org.apache.commons.lang.enums.Enum {
public static final MyEnum MY_FIRST_VALUE = new MyEnum("MyFirstValue");
public static final MyEnum MY_SECOND_VALUE = new MyEnum("MySecondValue");
public static MyEnum getEnum(String name) {
return (MyEnum) getEnum(MyEnum.class, name);
}
[...other standard enum methods]
}
The class in which to inject :
public class MyService {
private final MyEnum status;
public MyService(MyEnum status) {
this.status = status;
}
}
The application context :
<bean id="myService" class="MyService">
<constructor-arg index="0" value="MyFirstValue" />
</bean>
Of course, with this I have a no matching editors or conversion strategy found
error. Is there an easy integration between Spring and the Jakarta enums ? Or should I write my own PropertyEditor ?