@Test public void testResolveDisplayValueSync() { MultipleItemsTranslatedResolver resolver = new MultipleItemsTranslatedResolver(new TranslatorSync()); handler.async(); String value = resolver.resolveDisplayValue("A;B C;\"\"", new ValueCallback() { @Override public void value(final String value) { handler.done(new Runnable() { @Override public void run() { Assert.assertEquals("a;b c;(no value)", value); } }); } }); Assert.assertEquals("a;b c;(no value)", value); }
@Override public String resolveDisplayValue(String value, final ValueCallback onValue) { final Map<String, String> map = new LinkedHashMap<String, String>(); final String[] split = value.split(";"); synchronized (map) { for(final String idStr: split) { if(NO_VALUE.equals(idStr)) { setValue(split, map, idStr, NO_VALUE_DESC, onValue); continue; } String result = translator.translate(idStr, new ValueCallback() { @Override public void value(String value) { setValue(split, map, idStr, value, onValue); } }); if(result != null) { setValue(split, map, idStr, result, onValue); } } String resolvedValue; if(map.size() == split.length) { resolvedValue = resolve(split, map); } else { resolvedValue = "Loading..."; } onValue.value(resolvedValue); return resolvedValue; } }
MultipleItemsTranslatedResolver extends MultipleItemsResolver { @Override public String resolveDisplayValue(String value, final ValueCallback onValue) { final Map<String, String> map = new LinkedHashMap<String, String>(); final String[] split = value.split(";"); synchronized (map) { for(final String idStr: split) { if(NO_VALUE.equals(idStr)) { setValue(split, map, idStr, NO_VALUE_DESC, onValue); continue; } String result = translator.translate(idStr, new ValueCallback() { @Override public void value(String value) { setValue(split, map, idStr, value, onValue); } }); if(result != null) { setValue(split, map, idStr, result, onValue); } } String resolvedValue; if(map.size() == split.length) { resolvedValue = resolve(split, map); } else { resolvedValue = "Loading..."; } onValue.value(resolvedValue); return resolvedValue; } } }
MultipleItemsTranslatedResolver extends MultipleItemsResolver { @Override public String resolveDisplayValue(String value, final ValueCallback onValue) { final Map<String, String> map = new LinkedHashMap<String, String>(); final String[] split = value.split(";"); synchronized (map) { for(final String idStr: split) { if(NO_VALUE.equals(idStr)) { setValue(split, map, idStr, NO_VALUE_DESC, onValue); continue; } String result = translator.translate(idStr, new ValueCallback() { @Override public void value(String value) { setValue(split, map, idStr, value, onValue); } }); if(result != null) { setValue(split, map, idStr, result, onValue); } } String resolvedValue; if(map.size() == split.length) { resolvedValue = resolve(split, map); } else { resolvedValue = "Loading..."; } onValue.value(resolvedValue); return resolvedValue; } } MultipleItemsTranslatedResolver(Translator translator); }
MultipleItemsTranslatedResolver extends MultipleItemsResolver { @Override public String resolveDisplayValue(String value, final ValueCallback onValue) { final Map<String, String> map = new LinkedHashMap<String, String>(); final String[] split = value.split(";"); synchronized (map) { for(final String idStr: split) { if(NO_VALUE.equals(idStr)) { setValue(split, map, idStr, NO_VALUE_DESC, onValue); continue; } String result = translator.translate(idStr, new ValueCallback() { @Override public void value(String value) { setValue(split, map, idStr, value, onValue); } }); if(result != null) { setValue(split, map, idStr, result, onValue); } } String resolvedValue; if(map.size() == split.length) { resolvedValue = resolve(split, map); } else { resolvedValue = "Loading..."; } onValue.value(resolvedValue); return resolvedValue; } } MultipleItemsTranslatedResolver(Translator translator); @Override String resolveDisplayValue(String value, final ValueCallback onValue); }
MultipleItemsTranslatedResolver extends MultipleItemsResolver { @Override public String resolveDisplayValue(String value, final ValueCallback onValue) { final Map<String, String> map = new LinkedHashMap<String, String>(); final String[] split = value.split(";"); synchronized (map) { for(final String idStr: split) { if(NO_VALUE.equals(idStr)) { setValue(split, map, idStr, NO_VALUE_DESC, onValue); continue; } String result = translator.translate(idStr, new ValueCallback() { @Override public void value(String value) { setValue(split, map, idStr, value, onValue); } }); if(result != null) { setValue(split, map, idStr, result, onValue); } } String resolvedValue; if(map.size() == split.length) { resolvedValue = resolve(split, map); } else { resolvedValue = "Loading..."; } onValue.value(resolvedValue); return resolvedValue; } } MultipleItemsTranslatedResolver(Translator translator); @Override String resolveDisplayValue(String value, final ValueCallback onValue);  }