Search code examples
droolsrule-engine

Drools Question about equality in memberOf and contains


I would appreciate if someone would explain how memberOf and contains evaluates equality between objects.

  rule "Compare orders"
  when
    $u:   User( $order: order )
    Order( $order memberOf orderLines )  
  then
 //do stuff
  end

In this example I found , how does the engine determine the user's order is a memberOf the order lines?

Thank you


Solution

  • The memberOf operator is implemented by the following method: ContainsOperator.eval(). This method uses Collection.contains() to do the check.

    Hope it helps,