在 Drools 声明类型中包含函数
有没有办法将成员函数添加到 Drools 声明的类型中?也就是说,我想说的是:
declare Foo
bar : int
plugh : String
function String greeting()
{
return "Hello "+plugh+"!";
}
end
这不起作用(或者我不会写这篇文章),但我只是语法错误,还是在 Drools 中没有办法做到这一点?
Is there a way to add member functions to a Drools declared type? That is, I'd like to say something like:
declare Foo
bar : int
plugh : String
function String greeting()
{
return "Hello "+plugh+"!";
}
end
That doesn't work (or I wouldn't be writing this post), but do I just have the syntax wrong, or is there no way to do that in Drools?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在 Drools 声明的类型中包含函数(超出它在类中生成的支持 Bean 属性类型的函数)。如果您发现需要声明类型的函数,您可能应该在常规 Java 中创建它们,然后将它们导入到规则文件中。
You cannot include functions in a Drools declared type (above and beyond what it generates in the class to support Bean property types). If you find you need functions in a declared type you should probably create them in your regular Java then import them into your rule file.