Description: To use a rule property that can take its value in an enumeration, I think the preferred approach is an EnumeratedProperty. I create an EnumeratedProperty like this:
private static final String[] LABELS = { "foo", "bar" };
enum Foo { FOO, BAR }
private static final Foo[] CHOICES = { Foo.FOO, Foo.BAR };
public static final EnumeratedProperty<Foo> FOO_DESCRIPTOR = new EnumeratedProperty<>(
"fooChoice", "Choose a instance of Foo", LABELS, CHOICES, 0, 3.0f);
where the parameter 0 indicates the default index. But the value returned by getProperty is really weird:
- If the property was not explicitly given a value in the ruleset.xml, then
getProperty returns "foo" (a String)
- Otherwise,
getProperty returns an instance of Foo, which corresponds to the label given in the XML.
I would think it's abnormal that getProperty may return something other than a Foo, especially since it's an EnumeratedProperty<Foo>. Is that a bug or am I doing this wrong ?
Description: To use a rule property that can take its value in an enumeration, I think the preferred approach is an EnumeratedProperty. I create an EnumeratedProperty like this:
where the parameter
0indicates the default index. But the value returned bygetPropertyis really weird:getPropertyreturns"foo"(a String)getPropertyreturns an instance ofFoo, which corresponds to the label given in the XML.I would think it's abnormal that
getPropertymay return something other than aFoo, especially since it's anEnumeratedProperty<Foo>. Is that a bug or am I doing this wrong ?