I have a class like this :
public class CheckSetFilter<E extends Enum<E>>
{
public CheckSetFilter(CheckSetManager<E> pCheckSetManager, E pCheckSetId)
}
I have this enum :
public enum StubCheckId
{
STUBCHECK1, STUBCHECK2
}
I try to create such an object with Spring :
<bean id="checkSetFilter" class="com.iba.icomp.core.checks.CheckSetFilter">
<constructor-arg ref="checkSetManager"/>
<constructor-arg value="STUBCHECK1"/>
</bean>
It complains, it cannot convert from String to Enum. I guess this is because of the generic. It cannot know the type of enum to create. I also tried to give it a type hint, but no luck.
All you really have to do is to add a value
tag inside the constructor-arg
tag.
<bean id="checkSetFilter" class="com.iba.icomp.core.checks.CheckSetFilter">
<constructor-arg ref="checkSetManager"/>
<constructor-arg>
<value type="your.package.StubCheckId">STUBCHECK1</value>
</constructor-arg>
</bean>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With