The problem is exactly that smell is not an attribute of Cheesy (for this
Cheese example we could argue if that makes sense, but in my context it 's
impossible).
I thought I had an error from the drools plugin when using instanceof even
in eval, but I'll try that again, I think I tried eval(this instanceof ...).
In my case it would still mean writing something like
when
$person : Person ()
$cheese : Cheese( eval( $cheese instanceof FrenchCheese) ) from
$person.getLikes()
FrenchCheese( smell == "good" ) from $cheese
Overloading getLikes() would be more elegant. Still, for me these are
workarounds.
Would it be that strange or unconventional to have the from only match on
the required subclass?
Grtz
Evert
Wolfgang Laun-2 wrote:
If smell is a property of Cheese and not just of FrenchCheese you could
use
when
$person : Person ()
$c: Cheese( eval( $c instanceof FrenchCheese), smell == "good" )
from
$person.getLikes()
then
Also, I think that a selective retrieval with an overloaded version of
getLikes():
getLikes( Class clazz )
might be useful, avoiding useless elements in the returned collection.
-W
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/About-for-and-inherit...
Sent from the Drools - User mailing list archive at
Nabble.com.