[rules-users] matches / not maches

Wolfgang Laun wolfgang.laun at gmail.com
Wed Nov 27 08:17:19 EST 2013


On 27/11/2013, Peter Troelsen <peter.j.troelsen at gmail.com> wrote:
> Hey..
> I have encountered a problem using the 'maches' operator in drool.. I wanna
> write something like this (just made a simple example)
>
> rule "Hello World"
>     when
>     m: Message("5" matches "5")
>     then
>         System.out.println("Test");
> end
>
> But eclipse tells me " '"5" ~= "5"' must be an boolean expression ",

Indeed, it does with the above expression, but not when the left
operand is a field name. - File a JIRA, maybe it'll be fixed in 6.1.

> and i
> get an runtime error if i try to run it.. However if I use 'not matches' it
> works! Forcing me to do something like this:
>
>     when
>     not m: Message("5" not matches "5")

This is not the double negation of the above pattern but something
entirely different.

A better workaround would be
   "5".matches( "5" )

-W

>     then
>
>
> Any ideas how to fix this?
> - Thanks!
>
> --
> Peter
>


More information about the rules-users mailing list