See inline.
On 27/12/2013, anij <[email protected]> wrote:
>
> Hi,
> I'm facing problem when I'm using Map and > Operator in condition section.
> I'm using version 5.4.
>
> this is my RULE:
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> package resouces.rules
>
> import java.util.*;
>
> rule "Valid Age_BNG"
> agenda-group "Check user Eligibility_BNG"
> salience 1
> no-loop true
> when
> map : Map()
> eval(map.get("Age") > 18 )
This should work if map is Map<String,Integer>, but...
> then
> map.put("Age_Validation",true);
...this statement indicates that Boolean is acceptable as an entry
type of Map map, too...
> update(map);
> System.out.println("RULE : "+drools.getRule().getName() );
> end
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>
> And error message :
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> Rule Compilation error : [Rule name='Valid Age_BNG']
> resouces/rules/Rule_Valid_Age_BNG_d2a9c84690ba457b900a0578788bdd23.java
> (8:313) : The operator > is undefined for the argument type(s) Object, int
...and the error message even indicates that some compiler thinks that
the left hand side of the comparison has type java.Object. Therefore,
it is reasonable to assume that the Map map is not Map<String,Integer>
but Map<String,Object>.
Try a plain old Java-style cast where you are sure that the map
element is an Integer.
-W
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-5-4-DRL-Issues-using-java-util-Map-and-operator-in-Condition-tp4027435.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users