@Test public void testResolveDisplayValueAsync() { final LinkedList<String> expect = new LinkedList<String>(); ExpressionResolver resolver = new ExpressionResolver(new TranslatorAsync(expect)); expect.add("Loading..."); expect.add("(a OR b)"); handler.async(2); synchronized (expect) { String value = resolver.resolveDisplayValue("A OR B", new ValueCallback() { @Override public void value(final String value) { handler.done(new Runnable() { @Override public void run() { Assert.assertFalse("Unexpected: " + value, expect.isEmpty()); Assert.assertEquals(expect.removeFirst(), value); } }); } }); Assert.assertEquals("Loading...", value); } }
@Override public String resolveDisplayValue(String expr, ValueCallback onValue) { Node node = ExpressionParser.parse(expr); String value; SingleValueCallBack callBack = new SingleValueCallBack(onValue); if(resolve(node, translator, callBack, node, new HashSet<Node>(Collections.singleton(node)))) { value = ExpressionBuilder.build(node); callBack.value(value); } else { value = TranslateService.LOADING_MESSAGE; callBack.initValue(value); } return value; }
ExpressionResolver implements FilterResolver { @Override public String resolveDisplayValue(String expr, ValueCallback onValue) { Node node = ExpressionParser.parse(expr); String value; SingleValueCallBack callBack = new SingleValueCallBack(onValue); if(resolve(node, translator, callBack, node, new HashSet<Node>(Collections.singleton(node)))) { value = ExpressionBuilder.build(node); callBack.value(value); } else { value = TranslateService.LOADING_MESSAGE; callBack.initValue(value); } return value; } }
ExpressionResolver implements FilterResolver { @Override public String resolveDisplayValue(String expr, ValueCallback onValue) { Node node = ExpressionParser.parse(expr); String value; SingleValueCallBack callBack = new SingleValueCallBack(onValue); if(resolve(node, translator, callBack, node, new HashSet<Node>(Collections.singleton(node)))) { value = ExpressionBuilder.build(node); callBack.value(value); } else { value = TranslateService.LOADING_MESSAGE; callBack.initValue(value); } return value; } ExpressionResolver(Translator translator); }
ExpressionResolver implements FilterResolver { @Override public String resolveDisplayValue(String expr, ValueCallback onValue) { Node node = ExpressionParser.parse(expr); String value; SingleValueCallBack callBack = new SingleValueCallBack(onValue); if(resolve(node, translator, callBack, node, new HashSet<Node>(Collections.singleton(node)))) { value = ExpressionBuilder.build(node); callBack.value(value); } else { value = TranslateService.LOADING_MESSAGE; callBack.initValue(value); } return value; } ExpressionResolver(Translator translator); @Override String resolveDisplayValue(String expr, ValueCallback onValue); @Override String toRESTQuery(String value); Translator getTranslator(); }
ExpressionResolver implements FilterResolver { @Override public String resolveDisplayValue(String expr, ValueCallback onValue) { Node node = ExpressionParser.parse(expr); String value; SingleValueCallBack callBack = new SingleValueCallBack(onValue); if(resolve(node, translator, callBack, node, new HashSet<Node>(Collections.singleton(node)))) { value = ExpressionBuilder.build(node); callBack.value(value); } else { value = TranslateService.LOADING_MESSAGE; callBack.initValue(value); } return value; } ExpressionResolver(Translator translator); @Override String resolveDisplayValue(String expr, ValueCallback onValue); @Override String toRESTQuery(String value); Translator getTranslator();  }