Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

ibm odm - 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.

question from:https://stackoverflow.com/questions/66049009/classcastexception-string-vs-enum-when-using-static-domain-in-ibm-odm

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...