[rules-users] A Set of Rules but no match
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Aug 5 07:09:41 EDT 2010
I'm using code such as
KnowledgeRuntime knowledgeRuntime;
for( KnowledgePackage knowledgePackage:
knowledgeRuntime.getKnowledgeBase().getKnowledgePackages() ){
for( Rule rule: knowledgePackage.getRules() ){
}
}
to obtain rules, intending to construct a Set<Rule>. This, however, breaks
since repeated executions of
knowledgePackage.getRules() appear to return different objects and - this is
the evil thing -
org.drools.definitions.rule.impl.RuleImpl does not implement hashCode() and
equals(); hence
Set<Rules>( rule ).contains( rule ) fails for actually identical rules. I
consider this a bug in Drools (5.1).
org.drools.definitions.rule.impl.RuleImpl could easily retain a reference to
the org.drools.rule.Rule object from which it is built and delegate
hashCode/equals to that.
-W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100805/e4afb85e/attachment.html
More information about the rules-users
mailing list