[rules-users] Using field values of an ENUM in the decision table

Visu Nageswaran visu.nageswaran at in.ibm.com
Fri Jul 10 06:29:33 EDT 2009


Is the following rule in-valid?
____________
when 
$c: Computer()
eval($c.getMemory().getValue() == "512")
then
System.out.println("XXXXXXXX THIS IS IT XXXXXXXXXXX" );
___________
Can someone help me understand if eval is used incorrectly to invoke the
nested accessor method getValue()? Null pointer exceptions are thrown in
method org.drools.rule.EvalCondition.isAllowed

Thanks in advance,
-Visu




Visu Nageswaran wrote:
> 
> Hello, I am posting a simpler version of the actual requirement: 
> Class Computer has a field 'memory' of the enum type 'Memory' which is
> defined over integer values 
> - - - - - - - - - - 
> public enum Memory{ 
> MEM1(512), MEM2(1024), MEM3(2048); 
> public int value; 
> Memory(int i){this.value = i;} 
> public int getValue(){return value;} 
> } 
> - - - - - - - - - - 
> There is a requirement to model a decision table between memory and price 
> I am looking for the field constraint on the memory field to match to the
> values:
>  
> memory.???--> Price 
> 512 --> 100 
> 1024 --> 200 
> 2048 --> 300 
> 
> I tried memory.name, memory.name(), memory.value, memory.getValue(); Does
> this have to be done using template expressions say something like memory
> == Memory.reverseLookupEnum($param)
> 
> Any help, pointers in this regard would be appreciated. thanks. 
> -Visu
> 

-- 
View this message in context: http://www.nabble.com/Using-field-values-of-an-ENUM-in-the-decision-table-tp24391112p24424994.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list