Suppose I have a class MyClass
which can be instantiated either with String
or it have predefined static instances inside a class.
Something like this:
public class MyClass {
public final static MyClass A = new MyClass("A");
public final static MyClass B = new MyClass("B");
public final static MyClass C = new MyClass("C");
...
public MyClass(String name) {
...
}
}
Is it possible to create an ArrayList<MyClass>
bean in Spring config somehow? Something like
<bean id="sequence" class="...ArrayList">
<member class="...MyClass" value="A"/>
<member ... />
....
</bean>
UPDATE 1
Is it possible to write following way:
<bean id="sequence" class="...ArrayList">
<constructor-arg>
<list>
<bean class="...MyClass" constructor-arg="A"/>
<bean class="...MyClass" constructor-arg="B"/>
<bean class="...MyClass" constructor-arg="C"/>
</list>
</constructor-arg>
</bean>