Hi
I'm working on Drools 3.06. I am not able to decipher the drl snippet you have posted.
I'am not clear about the <b>'from collect'</b> Keywords. My problem statement is to get the number of
occurance of a Student(Name =="Drools") in a collection.
Please find below a small java snippet which is equivalent to what I'm tring to do.
int count = 0;
List<Student> nameList = getListofNames();
while(nameList.iterator().hasNext())
{
Student student = (Student)nameList.iterator().next();
if(Student.getName.equals ("Drools"))
{
count++;
}
}
System.out.println("Occurance Count" + count);
Edson Tirelli-3 wrote:
>
> Nope, if you want actual instances you must use "collect":
>
> when
> context : Context(state == Context:START_UP)
> list : ArrayList( size > 0 ) from collect( ClassName(varName =="value" )
> )
> then
> // list has your matching ClassName objects
> end
>
> []s
> Edson
>
>
>
> 2007/6/1, Rajesh.Sachin10 <rajesh_sachin10@yahoo.co.in>:
>>
>>
>> Its possible to use 'exists' keyword to get the number of occurance?
>>
>> Eg:
>>
>> context : Context(state == Context:START_UP) exists ClassName(varName ==
>> "value")
>>
>>
>> The ClassName is an Object array..... So to get the number of occurance
>> of
>> the "value" in varName, we have any method or keywords?
>> --
>> View this message in context:
>> http://www.nabble.com/Usage-of-%27exists%27-keyword-to-get-the-number-of-occurance--tf3853750.html#a10917875
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
> Edson Tirelli
> Software Engineer - JBoss Rules Core Developer
> Office: +55 11 3529-6000
> Mobile: +55 11 9287-5646
> JBoss, a division of Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
Quoted from:
http://www.nabble.com/Usage-of-%27exists%27-keyword-to-get-the-number-of-occurance--tf3853750.html#a10918988