question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to define new matcher function?

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
hsluoyzcommented, Oct 19, 2019

@M-Razavi jCasbin 1.2.0 has been released to Maven, may need some time for cache: https://mvnrepository.com/artifact/org.casbin/jcasbin

1reaction
hsluoyzcommented, Jan 24, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >
Hamcrest Custom Matchers - Baeldung
Learn how to create custom matchers using Hamcrest.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found