Search code examples
jess

A deftemplate code in Jess programing


I saw such code in a paper:

(import com.psy.entity.Record) 

Can this statement import a Java class?

(deftemplate Record(declare(from-class Record))) 

I don't understand this statement, how to use the declare statement, is there a function in Jess named from-class, I think I have never seen such function in the book of Jess in Action.

(defrule show-test-result-20
?0<-(Record {score<=30}))

I think it's better to do this test by the test conditional element, is this code right?


Solution

  • "Can...class?" -> Yes, that's why you have the import statement. See the Jess manual.

    (deftemplate Record (declare (from-class Record)))
    

    This declares a fact type Record as a shadow fact for class `Record*. This is discussed and explained in the Jess manual.

    "I think...?" -> No, the rule is perfectly all right and preferable.