[rules-users] Maps as Object in Drools

Mark Proctor mproctor at codehaus.org
Sun Aug 19 09:57:44 EDT 2012


We don't publicise the internal javadocs, just the public ones. But just checkout the code and look over it, I don't think the internal javadocs will help much.

You lose type discrimination and type safety, but you can already do:
Map( this['key'] == "xxx" )

What I think would be more interesting is to use Traits and map a Map to a type safe structure. It would take a some changes, as at the moment the Traits back onto a global triple store, but they could with some changes back onto the provided Map instance. Traits is a form of duck typing.
 
//code below is illustrative of what is possible, if changes where mad for above idea.

// Create interface
Person
    @Trait
    String : name
    int       : age
end

// Identify the Map instance, and wrap it with the Person interface.
rule
   $m : Map[ this['name'] != null, this['age'] != null )
then
    don( $m : Person.class );
end

// Now the map is identified in a type safe manner.
rule
    Person( name == "darth", age == 150 )
then
    ….
end



On 19 Aug 2012, at 13:56, Frank Wilson <fajwilson at gmail.com> wrote:

> Hi All,
> 
> I was reading the following thread from august 2009:
> 
> http://lists.jboss.org/pipermail/rules-users/2009-August/010178.html
> 
> I would like write a clojure DSL for drools similar to what André was trying to do and I also feel that using maps as fact-objects would be the most idiomatic for Clojure (at least in the general case!).
> 
> I am interested by the idea of implementing ObjectType and Accessor interfaces proposed by Edson. It seems that this would be a good fit with Drools and that (if understand correctly!) it would allow the map properties to be properly indexed by the rules engine. However I cannot seem to find these interfaces (ObjectType and *Accessor) in the current API.
> 
> http://docs.jboss.org/drools/release/5.4.0.CR1/knowledge-api-javadoc/index.html
> 
> Could someone show me where these classes are documented? Or were they moved or replaced? Maybe there is some source code that would make a good example?
> 
> Thanks for your help,
> 
> Frank
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120819/1ebe4d8a/attachment.html 


More information about the rules-users mailing list