JESS: [EXTERNAL] Code to convert a POJO to a template assertion?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

JESS: [EXTERNAL] Code to convert a POJO to a template assertion?

Grant Rettke
Hi,

For whatever reason I don't want to use defclass and instead want to be able to convert a POJO to a template assertion. There are helpers to write converters like this but I'm wondering if someone has done it? Maybe it could even define the deftemplate given the class.

It would be like:

class Person {
String name;
int age;
public void getName() { return name; }
public void getAge() {return age; }

The functions might do this:

pojoToTemplate(Object o) -> string

pojoToAssertion(Object o) -> string

Person p = new Person("Joe", 10);

pojoToTemplate(p) -> "(deftemplate (slot name) (slot age))

pojoToAssertion(p) -> "(assert (Person (name "Joe") (age 10))

Ok the reason is that I don't want or plan to deal with modifying any state outside of the engine environment :).

Best wishes,

--
Grant Rettke | ACM, AMA, COG, IEEE
[hidden email] | http://www.wisdomandwonder.com/
Wisdom begins in wonder.
((λ (x) (x x)) (λ (x) (x x)))