解析公式Aviator简单使用

pom引入:

<dependency>
    <groupId>com.googlecode.aviator</groupId>
    <artifactId>aviator</artifactId>
    <version>5.2.4</version>
</dependency>

简单测试:

 public static void main(String[] args) {
        String fun = "(a+b)/3";
        Map map = new HashMap<>();
        map.put("a",11);
        map.put("b",22);
        Object execute = AviatorEvaluator.execute(fun, map);
        System.out.println(execute);
    }

执行方式
执行表达式的方法有两个:execute()、exec();
execute(),需要传递Map格式参数
exec(),不需要传递Map

官方详细文档:
https://code.google.com/archive/p/aviator/wikis/User_Guide_zh.wiki

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容