package com.storlead.framework.common.aviator;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorBoolean;
import com.googlecode.aviator.runtime.type.AviatorObject;

import java.util.Map;

/**
 * @program: sp-cloud
 * @description:
 * @author: chenkq
 * @create: 2022-04-26 15:44
 */
public class EqualsFunction extends AbstractFunction {
    @Override
    public AviatorBoolean call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {

        String num1 = FunctionUtils.getStringValue(arg1, env);
        String num2 = FunctionUtils.getStringValue(arg2, env);
        return AviatorBoolean.valueOf(num1.equals(num2));
    }

    @Override
    public String getName() {
        return "myequals";
    }

    public static String getFunctionName() {
        return "myequals";
    }
}
