Skip to content

Commit

Permalink
Merge pull request #181 from aaronlinv/master
Browse files Browse the repository at this point in the history
fix: bugs in KeyGet2Func and KeyGetFunc
  • Loading branch information
hsluoyz authored Apr 27, 2021
2 parents 02142b3 + 0efc4ad commit ec22a57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

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 com.googlecode.aviator.runtime.type.AviatorString;
import org.casbin.jcasbin.util.BuiltInFunctions;

import java.util.Map;
Expand All @@ -30,15 +30,16 @@
*/
public class KeyGet2Func extends AbstractFunction {
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2, AviatorObject arg3) {
String key1 = FunctionUtils.getStringValue(arg1, env);
String key2 = FunctionUtils.getStringValue(arg2, env);
String pathVar = FunctionUtils.getStringValue(arg3, env);

return AviatorBoolean.valueOf(BuiltInFunctions.keyMatch(key1, key2));
return new AviatorString(BuiltInFunctions.keyGet2Func(key1, key2, pathVar));
}

@Override
public String getName() {
return "ketGet2";
return "keyGet2";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

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 com.googlecode.aviator.runtime.type.AviatorString;
import org.casbin.jcasbin.util.BuiltInFunctions;

import java.util.Map;
Expand All @@ -34,7 +34,7 @@ public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorOb
String key1 = FunctionUtils.getStringValue(arg1, env);
String key2 = FunctionUtils.getStringValue(arg2, env);

return AviatorBoolean.valueOf(BuiltInFunctions.keyMatch(key1, key2));
return new AviatorString(BuiltInFunctions.keyGetFunc(key1, key2));
}

@Override
Expand Down

0 comments on commit ec22a57

Please sign in to comment.