Re: [rules-users] check list size
Thanks for the example Mike just upgraded to 6.1.CR2 it's working in it. Just need to add a BRL fragment if want to you in a Decision table. Thanks and Regards On Mon, Jul 14, 2014 at 4:58 PM, Michael Anstis wrote: > I had a look, but was able to use a List without problem (6.1.CR2): > > 1) Made a Maven-ized JAR containing the following class: > > package org.anstis; > > import java.util.List; > > public class MyListClass { > > private List myList; > > public List getMyList() { > return myList; > } > > public void setMyList( List myList ) { > this.myList = myList; > } > } > > 2) Uploaded JAR to the workbench's Artifact Repository > > 3) Added a project dependency on this artifact > > 4) Added an Import Suggestion for java.util.List > > 5) Created a new Guided Rule > > 6) Imported MyListClass and java.util.List (Config tab) > > 7) Created the following rule: > > package org.mortgages; > > import java.lang.Number; > import java.util.List; > import org.anstis.MyListClass; > > rule "r1" > dialect "mvel" > when > MyListClass( myList.size() < 5 ) > then > end > > You need to use an "Expression" to use the "size()" method call (as it is > not a field, but a method call). Fields are "getXXX" or "setYYY" or public > members. > > With kind regards, > > Mike > > On 11 July 2014 15:14, Sumit Dhaniya wrote: > >> I have a class which contains some lists, I want to apply rules on size of >> list and want to use functions like first(), last() but list objects which >> are in my class are identified as collections and only collection related >> functions are shown. >> >> For eg. >> >> class A { >> java.util.List bList = new ArrayList(); >> } >> >> now it shows bList as collection type and it doesn't shows size and >> related >> list function instead shows collection functions like contains etc. >> >> Can't I use it like both a collection as well as List? >> >> I tried importing java.util.List but it still don't recognize my List >> objects as List >> >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/check-list-size-tp4030303.html >> Sent from the Drools: User forum mailing list archive at Nabble.com. >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] check list size
I had a look, but was able to use a List without problem (6.1.CR2): 1) Made a Maven-ized JAR containing the following class: package org.anstis; import java.util.List; public class MyListClass { private List myList; public List getMyList() { return myList; } public void setMyList( List myList ) { this.myList = myList; } } 2) Uploaded JAR to the workbench's Artifact Repository 3) Added a project dependency on this artifact 4) Added an Import Suggestion for java.util.List 5) Created a new Guided Rule 6) Imported MyListClass and java.util.List (Config tab) 7) Created the following rule: package org.mortgages; import java.lang.Number; import java.util.List; import org.anstis.MyListClass; rule "r1" dialect "mvel" when MyListClass( myList.size() < 5 ) then end You need to use an "Expression" to use the "size()" method call (as it is not a field, but a method call). Fields are "getXXX" or "setYYY" or public members. With kind regards, Mike On 11 July 2014 15:14, Sumit Dhaniya wrote: > I have a class which contains some lists, I want to apply rules on size of > list and want to use functions like first(), last() but list objects which > are in my class are identified as collections and only collection related > functions are shown. > > For eg. > > class A { > java.util.List bList = new ArrayList(); > } > > now it shows bList as collection type and it doesn't shows size and related > list function instead shows collection functions like contains etc. > > Can't I use it like both a collection as well as List? > > I tried importing java.util.List but it still don't recognize my List > objects as List > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/check-list-size-tp4030303.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] check list size
I have a class which contains some lists, I want to apply rules on size of list and want to use functions like first(), last() but list objects which are in my class are identified as collections and only collection related functions are shown. For eg. class A { java.util.List bList = new ArrayList(); } now it shows bList as collection type and it doesn't shows size and related list function instead shows collection functions like contains etc. Can't I use it like both a collection as well as List? I tried importing java.util.List but it still don't recognize my List objects as List -- View this message in context: http://drools.46999.n3.nabble.com/check-list-size-tp4030303.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users