这里的表达式只要是任何返回Boolean的表达式即可,框架提供两个占位符,#current和#root,其中#current表示当前属性的值,#root表示的是当前属性所在的对象的值,可以通过#root.xxx访问其他的属性。该表达式支持java中的任何符号操作,此外还支持java.lang.math中的所有静态函数,比如:min、max和abs等等
@Data@Accessors(chain = true)public class ConditionEntity {/*** 当前属性和属性num3的值大于100*/@Matcher(condition = "#current + #root.num2 > 100")private Integer num1;/*** 当前属性的值小于 20*/@Matcher(condition = "#current < 20")private Integer num2;/*** 当前属性的值大于31并自增*/@Matcher(condition = "(++#current) >31")private Integer num3;/*** 当前属性的值大于31并自增*/@Matcher(condition = "(++#current) >31")private Integer num4;/*** 其中某个属性为true*/@Matcher(condition = "#root.judge")private Integer age;private Boolean judge;/*** 当前值和另外值的最小值大于第三个值*/@Matcher(condition = "min(#current, #root.num6) > #root.num7")private Integer num5;private Integer num6;private Integer num7;}
