I am using the JavaScript Engine in Java to evaluate some strings. I want user.group == group1
in JavaScript to evaluate the Java method user.hasGroup(group1)
. User contains a list of group strings.
I know I can bind functions with the following, but I am not sure how to replace the equality operator and use the right side as a parameter. (jsEngine is my JavaScript engine)
Bindings b = jsEngine.createBindings();
b.put(String name, Object value);
Engine.setBindings(Bindings bindings, int scope);