在 Drools 声明类型中包含函数

发布于 2024-11-24 09:02:50 字数 243 浏览 4 评论 0原文

有没有办法将成员函数添加到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-12-01 09:02:50

您不能在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文