Brainteaser Drools: Testing Objects

This can be a hard one, since it requires from you to be familiar with Drools.

Consider the condition side of the following rules:

rule "object comparison one"
no-loop

when
	$customer1 : Customer( )
	$customer2 : Customer(this != $customer1)
then
	System.out.println("Rule one - Objects are equal");
end
rule "object comparison two"
no-loop

when
	$customer1 : Customer( )
	$customer2 : Customer(eval(this != $customer1))
then
	System.out.println("Rule two - Objects are equal");
end

Question(s):
Which of the two rules does valid comparison of the two Customer instances?
Which of the two rules is invalid? Why?

Looking forward for your answers dear readers

Resources:
Drools JBoss Rules 5.0 Developer’s Guide July 2009

More from Alexander Zagniotov:

  1. Drools – Stop Executing Current Agenda Group and All Rules
    Sometimes, depends on your business rules in your application, there is a need to stop current agenda group or all...
  2. Drools – Working with Stateless Session
    Drools (now it is also called JBoss Rules) is an amazing open source framework which allows you to create business...
  3. Drools – Tutorial on Writing DSL Template
    Few months ago I wrote a post that describes an example that uses source DRL in conjunction with DSL template....
  4. Hibernate – How To Map Two Collections of The Same Type in The Same Entity
    Recently during development, I encountered a situation where I had to map two collections in the same entity, having collections...
  5. Marshalling VS Serialization
    The two terms are very very similar, and often treated the same. Quite few responds on various forums contradict each...

 

Comments
  • Alexander Zagniotov August 23, 2009 at 11:03 am

    Brainteaser Drools: Testing Objects:
    This can be a hard one, since it requires from you to be familiar with Dr.. http://bit.ly/4wykv0