[rules-users] Facts - can they be non Java Beans

Edson Tirelli tirelli at post.com
Thu May 8 14:13:50 EDT 2008


     Drools does not look at the class attributes. All he cares are the
methods. In your example:

rule "Some Rule"
 when
       $MyFact :A( $first : first )
  then

    Will work just fine, because when drools see "first", he will look for a
method called either "getFirst()" or "isFirst()" or in last case "first()".

    []s
    Edson



2008/5/8 sridhar123 <sridhar.peddinti at sabre.com>:

>
> I am trying to access Fact objects that are not always java beans. Example:
>
> Class A {
>  Arraylist  Class B b
>
>  getFirst() { return b.first() }
>
>  }
>
> In above Class i dont have any variable called "first" - but returning
> first
> element of the list.
>
> Now following DRL throws compilation errors.
>
> rule "Some Rule"
>  when
>        $MyFact :A()
>        $first : $myFact.getFirst()
>   then
>       ....
>       ....
> end
>
> Is there any way to execute the above - or i should have class variable
> "first" and access that?
>
> thank you
> Sridhar
> --
> View this message in context:
> http://www.nabble.com/Facts---can-they-be-non-Java-Beans-tp17130130p17130130.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080508/26de99c4/attachment.html 


More information about the rules-users mailing list