java - Hamcrest CombinableMatcher 的评估顺序
问题描述
我想为匹配器编写一个逻辑,例如matcher_1 AND matcher_2 OR matcher_3 and matcher_4
hamcrestmatcher_i
匹配器的占位符。
我决定这样写CombinableMatcher
-
new CombinableMatcher<String>(matcher_1).and(matcher_2).or(matcher_3).and(matcher_4)
现在,问题是匹配器的评估顺序是什么?
会是((((matcher_1) AND matcher_2) OR matcher_3) and matcher_4)
还是其他类似的命令((matcher_1 AND matcher_2) OR (matcher_3 and matcher_4))
?
解决方案
很高兴看到有人理解编写匹配器的想法。
我想知道你为什么关心匹配器的顺序?理想情况下,这无关紧要,因为您也不知道匹配器被调用的频率。
如果您在此详细程度遇到问题,最好编写自定义匹配器。
推荐阅读
- javascript - 在 Route 的渲染部分中未调用函数
- javascript - 如何有条件地在 javascript 对象 reduce 中添加道具?
- django - 将文本模型中的作者姓名渲染为 django 中的外键
- android - 如何使用 Android 导航组件和深度链接打开活动和特定目的地
- c# - 如何在 sortedList 中获取特定值的范围键
- java - 无法创建请求的服务 [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]?
- codenameone - 代号一中的连字符?
- c++ - 仅使用 iostream 和 iomanip 库时在 c++ 中引用 ios 库
- forms - PowerShell 表单未返回预期输出
- python - 等待第 N 个元素的可见性