@Test public void umaSimulation() throws ScriptException { String rule = "{" + " \"and\": [ {" + " \"or\": [" + " {\"var\": 0 }," + " {\"var\": 1 }" + " ]" + " }," + " {\"var\": 2 }" + " ]}"; Assert.assertTrue(JsonLogic.apply(rule, "[true, true, true]")); Assert.assertTrue(JsonLogic.apply(rule, "[true, false, true]")); Assert.assertTrue(JsonLogic.apply(rule, "[false, true, true]")); Assert.assertFalse(JsonLogic.apply(rule, "[false, false, false]")); Assert.assertFalse(JsonLogic.apply(rule, "[false, false, true]")); Assert.assertFalse(JsonLogic.apply(rule, "[true, true, false]")); }
public static boolean apply(String rule) throws ScriptException { return applyObject(rule).equals(Boolean.TRUE); }
JsonLogic { public static boolean apply(String rule) throws ScriptException { return applyObject(rule).equals(Boolean.TRUE); } }
JsonLogic { public static boolean apply(String rule) throws ScriptException { return applyObject(rule).equals(Boolean.TRUE); } private  JsonLogic(); }
JsonLogic { public static boolean apply(String rule) throws ScriptException { return applyObject(rule).equals(Boolean.TRUE); } private  JsonLogic(); static JsonLogic getInstance(); ScriptEngine getEngine(); Invocable getInvocable(); static Object eval(String script); static Object invokeFunction(String name, Object... args); static boolean apply(String rule); static boolean apply(String rule, String data); static Object applyObject(String rule); static Object applyObject(String rule, String data); }
JsonLogic { public static boolean apply(String rule) throws ScriptException { return applyObject(rule).equals(Boolean.TRUE); } private  JsonLogic(); static JsonLogic getInstance(); ScriptEngine getEngine(); Invocable getInvocable(); static Object eval(String script); static Object invokeFunction(String name, Object... args); static boolean apply(String rule); static boolean apply(String rule, String data); static Object applyObject(String rule); static Object applyObject(String rule, String data);  }