ibm-odmjrules

ClassCastException String vs Enum when using Static Domain in IBM ODM


I followed the tutorial here to create a static enum

For a domain value EXAMPLE, I would verbalise it to 'Example' and manually define the Getter (in ARL) as return "Example"; as explained in the tutorial.

Then I define an input/output variable myDomainExample and try testing it through the REST API.

If I write a dummy rule such as:

then
   set 'my domain example' to Example; 

I get this json result:

{
   "__DecisionID__": "144805689948397501147221553",
  "myDomainExample ": "Example"
 }

If I write the following dummy rule though:

 if 
    'my domain example' is Example 
 then
    set 'my domain example' to Example; 

and I enter the following json payload:

{
  "__DecisionID__": "144805689948397501147221553",
  "myDomainExample ": "Example"
 }

I get this error message:

java.lang.ClassCastException: java.lang.String incompatible with java.lang.Enum

Does anyone know what is causing this? I also tried using capital letters and it didn't work either.

I could alternatively write a Java class for this domain but I'd rather not.


Solution

  • I found the problem, I mistakenly used 2 superclasses when defining this (Object and Enum).

    Using only one (Object, as defined in the linked tutorial) solved the problem