Skip to content

Condition matching DSL(规则匹配DSL实现)

Notifications You must be signed in to change notification settings

wForget/MatcherDSL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MatcherDSL

实现 matcher dsl 表达式,实现规则匹配功能(类似规则引擎)。

Features

  • 支持算术运算符 + - * /
  • 支持条件运算符 > >= < <= =
  • 支持正则匹配 =~
  • 支持逻辑运算符 AND OR
  • 支持定义函数

Use Demo

    String matchDsl = "lower(name) = lower(\"WangZ\") and age > 20 and age < 30 and (interest = \"basketball\" or interest = \"football\") and desc =~ \"hello.*\"";
    Map<String, Object> variableMap = new HashMap<>();
    variableMap.put("name", "WANGZ");
    variableMap.put("age", 25);
    variableMap.put("interest", "basketball");
    variableMap.put("desc", "hello wangz");
    Matcher matcher = new Matcher(matchDsl, variableMap);
    Assert.assertEquals(matcher.match(), true);

说明

  1. 定义函数

可在 cn.wangz.matcher.function.impl 包中实现新的函数,继承 IFunction 接口,添加 @Function 注解并实现 execute 方法。

参考

About

Condition matching DSL(规则匹配DSL实现)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published