Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以实现 继承了OperatorBase的Function加别名吗 #100

Open
wadekun opened this issue Jul 1, 2020 · 2 comments
Open

可以实现 继承了OperatorBase的Function加别名吗 #100

wadekun opened this issue Jul 1, 2020 · 2 comments

Comments

@wadekun
Copy link

wadekun commented Jul 1, 2020

您好,可以实现 继承了OperatorBase的Function加别名吗?比如 expressRunner().addFunction(name, alias, OperatorBase);

@DQinYuan
Copy link
Collaborator

DQinYuan commented Dec 8, 2020

试试看宏?

@MoonNigth
Copy link

版本:3.3.2
可以使用addOperatorWithAlias给函数起别名,但是函数的实现类需要存在三个字符串入参的构造函数

    public ConcatFunction(String aliasName, String name, String errorInfo) {
        this.name = name;
        this.aliasName = aliasName;
        this.errorInfo = errorInfo;
    }
    @Test
    public void zsTest() throws Exception {
        ExpressRunner runner = new ExpressRunner(true, false);
        DefaultContext<String, Object> context = new DefaultContext<String, Object>();
        runner.addFunction("concatFunc", new ConcatFunction());
        runner.addOperatorWithAlias("拼接函数","concatFunc","");
        // 定义表达式
        String express = "拼接函数(\"A\",\"B\")";
        System.out.println("表达式结果:" + runner.execute(express, context, null, true, true));

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants