How to define new matcher function?
See original GitHub issueI’ve written a function but now how should add it to function map?
public class InCollectionFunc extends AbstractFunction {
public InCollectionFunc() {
}
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2, AviatorObject arg3) {
String value = FunctionUtils.getStringValue(arg1, env);
String collection = FunctionUtils.getStringValue(arg3, env);
return AviatorBoolean.valueOf(isInCollection(value, collection));
}
private boolean isInCollection(String value,String collection) {
System.out.println("value:" + value + " isIn collection:" + collection);
return true;
}
public String getName() {
return getNameStatic();
}
public static String getNameStatic() {
return "isIn";
}
}
enforcer = new Enforcer("erole.conf", "policy.csv");
enforcer.addFunction(InCollectionFunc.getNameStatic(),new InCollectionFunc());
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
MATCH function - Microsoft Support
The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in...
Read more >Creating custom matchers — callee 0.3 documentation
The simplest technique is based on (re)using a predicate – that is, a function that returns a boolean result ( True or False...
Read more >Define a custom matcher - RSpec Expectations - Relish
rspec-expectations provides a DSL for defining custom matchers. These are often useful for expressing expectations in the domain of your application.
Read more >Writing Custom Matchers - jMock
jMock and Hamcrest 1 provide many Matcher classes and factory functions that let you specify the acceptable parameter values of a method invocation...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@M-Razavi jCasbin
1.2.0
has been released to Maven, may need some time for cache: https://mvnrepository.com/artifact/org.casbin/jcasbin@M-Razavi Aviator needs to release a new version before jCasbin can import it. You can ask its author to release one and I will release a new version jCasbin based on it.