gpt4 book ai didi

drools - Drools 中的 Mvel 方言是什么?

转载 作者:行者123 更新时间:2023-12-02 08:35:58 39 4
gpt4 key购买 nike

我是 Drools 新手。我正在创建规则,但出现编译时错误

"field is not visible'.

我尝试检查 Jboss 示例,其中使用方言“mvel”。它编译了。我听不懂方言。那么 dialect=mvel 是什么?

最佳答案

mvel,或 MVFLEX Expression Language有一个rich syntax ,其中许多允许比 java 更简洁、更具表现力的代码(并且命令性更少),例如

  • 以替代 property 样式语法访问 get()ters/set()ters(例如封装私有(private)字段)的简写(类似于VB or C# properties in .Net)

即。而不是

myObject.setSomeField("SomeValue");
int x = myObject.getSomeIntField();

您可以使用语法(还要注意微妙的大小写切换):

myObject.someField = "SomeValue"
x = myObject.someIntField // Type inferrence
  • return 语句是可选的(Scala 等许多函数式语言中都有这种约定),分号也是可选的,除非每行有多个语句:

x  // i.e. return x;
  • 简写数组创建和按序数索引

foos = {2, 4, 6, 8, 10}
foos[3] // foos.get(3)
  • map (字典)也类似

bars = ["a" : "Apple", "b" : "Basket"] // Hashmap, with put
bars["a"]
bars.a // Similar to dynamically typed object e.g. in javascript, if key is a string.
  • Null 安全导航运算符(如 Rosyln 中的 null 条件运算符)

foo.?bar.baz // if (foo.bar != null) { return foo.bar.baz; } else { return null; }

关于drools - Drools 中的 Mvel 方言是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17259341/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com