I have a property of int and I have an enum. How can I set the int property using the enum in Spring bean configuration?
public class HelloWorld {
private int type1;
public void setType1(int type1) {
this.type1 = type1;
}
}
public enum MyEnumType1 {
TYPE1(1),
TYPE2(2);
private final int index;
private MyEnumType1(int i) {
this.index = i;
}
public int getIndex() {
return index;
}
}
I tried the following but did not work.
<bean id="helloBean" class="com.example.HelloWorld">
<property name="type1" value="TYPE1.index" />
</bean>