Hi,

I have not fully grasped how Jess deals with Java class/interface inheritance for LHS checks. How must I use (defclass) and/or (deftemplate w/ from-class) and/or (deftemplate w/ extends) to make Jess trigger rules where a fact's java object would be an instanceof a "LHS type"

For example:
class A { Collection getCol() /* of IF */ }
interface IF { String getName() }
class C implements IF { String getName(); Integer getId() }
class D extends C { String getHobby(); }
class E implements IF { String getName(); String getCity() } /* not related to C / D, just same IF */

lets assume I assert an object a::A with col = { c::C, d::D, e::E }, rules following: (defclass A A nil) (defclass IF IF nil) (defclass C C nil) (defclass D D C) (defclass E E nil) (defrule r1 (A (col ?col)) => (foreach ?i ?col (definstance IF ?i))) /* fire for a
   if (definstance IF ?i) r2 will fire, but not r3 - r5?
if (add ?i) would use concrete class C, D, E but then r2 would not fire? */ (defrule r2 (IF (name ?name)) => (printout t "name=" ?name)) /* fire for c, d, e */
(defrule r3 (C (id ?id)) => (printout t "id=" ?id)) /* fire for c, d */
(defrule r4 (D (hobby ?hobby)) => (printout t "hobby=" ?hobby)) /* fire for d */
(defrule r5 (E (city ?city)) => (printout t "city=" ?city)) /* fire for e */

Is it possible to completely mirror class/interface inheritance for Jess templates/rules? If not, what workarounds are possible e.g. to trigger the above rules for the facts given as desired?

thanks in advance, Juergen

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to