2

I have a follow up question to this solution to extending java enums.

How do I inject the extended enums via Spring config when a bean has the interface as property. For example,

class Foo {
  Day dayProp;

  public setDayProp(Day day) {
     this.dayProp = day;
  }
}

This gives an error 'failed to convert java.lang.String to interface Day'. I've also tried specifying the entire path.

<bean id="foo1" class="Foo">
  <property name="dayProp" value="SAT" />
</bean>
Community
  • 1
  • 1
Darth Ninja
  • 1,049
  • 2
  • 11
  • 34

2 Answers2

4

With a bit of experimentation, I got this working using SpEL

<property name="dayProp" value="#{ T(path.for.WeekendDay).SAT }" />

But I would love to hear of alternative solutions.

Darth Ninja
  • 1,049
  • 2
  • 11
  • 34
-1

Spring uses reflection to determine the type of property anyway. Have you tried just "SAT"?

masted
  • 1,211
  • 2
  • 8
  • 14