测试是否在规则左侧的 BitSet 中设置了一个位
我有一个 BitSet 成员,在给定的规则中,我想测试是否设置了特定位,例如:
class Foo
{
BitSet bar;
// getter & setter
}
我想要的规则:
rule "Test Bitset"
when
$f : Foo(bar ???) <-- what does this look like?
then
// do something
end
这可能吗?
I have a member which is a BitSet
, and in a given rule, I'd like to test whether a particular bit is set, for example:
class Foo
{
BitSet bar;
// getter & setter
}
My rule that I would like:
rule "Test Bitset"
when
$f : Foo(bar ???) <-- what does this look like?
then
// do something
end
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据文档,
这是一种有效的方法。
Drools 文档
According to the docs
would be a valid way to do it.
Drools doc
像这样的事情是有效的:
打印“true”,因为十进制 10 的 BitSet 结果为二进制 1010,第 4 位(从右侧读取,零索引)是 1,所以 true。
您应该能够将其转换到您的算法中。
Something like this works:
That prints "true" as the BitSet for decimal 10 results in binary 1010, the 4th bit (reading from the right, zero indexed) is 1, so true.
You should be able to transpose that into your algorithm.