@Test public void ruledLanguageBidirectional() { LanguageIndex index = new LanguageIndex.Builder() .add(lp("en zh-CN")) .add(lp("en zh-TW")) .add(lp("zh en")) .addRule(p("zh * HK"), l("zh-TW")) .addRule(p("zh * *"), l("zh-CN")) .build(); assertEquals(lp("en zh-CN"), index.map(lp("en zh"))); assertEquals(lp("en zh-CN"), index.map(lp("en zh-CN"))); assertEquals(lp("en zh-CN"), index.map(lp("en zh-Hans-CN"))); assertEquals(lp("en zh-CN"), index.map(lp("en zh-XX"))); assertEquals(lp("en zh-TW"), index.map(lp("en zh-TW"))); assertEquals(lp("en zh-TW"), index.map(lp("en zh-HK"))); assertEquals(lp("en zh-TW"), index.map(lp("en-US zh-HK"))); assertEquals(lp("zh en"), index.map(lp("zh en"))); assertEquals(lp("zh en"), index.map(lp("zh-CN en"))); assertEquals(lp("zh en"), index.map(lp("zh-XX en"))); assertEquals(lp("zh en"), index.map(lp("zh-TW en"))); assertEquals(lp("zh en"), index.map(lp("zh-HK en"))); assertEquals(lp("zh en"), index.map(lp("zh-HK en-US"))); assertEquals(lp("zh en"), index.map(lp("zh-Hans-HK en-Latn-US"))); }
public LanguageDirection map(LanguageDirection pair) { return mappingCache.computeIfAbsent(pair, this::search); }
LanguageIndex { public LanguageDirection map(LanguageDirection pair) { return mappingCache.computeIfAbsent(pair, this::search); } }
LanguageIndex { public LanguageDirection map(LanguageDirection pair) { return mappingCache.computeIfAbsent(pair, this::search); } private  LanguageIndex(Map<SimpleLanguageDirection, List<LanguageDirection>> index, Map<String, List<LanguageRule>> rules, Map<LanguageDirection, LanguageBridge> pivots); }
LanguageIndex { public LanguageDirection map(LanguageDirection pair) { return mappingCache.computeIfAbsent(pair, this::search); } private  LanguageIndex(Map<SimpleLanguageDirection, List<LanguageDirection>> index, Map<String, List<LanguageRule>> rules, Map<LanguageDirection, LanguageBridge> pivots); Set<LanguageDirection> getLanguages(); int size(); LanguageDirection asSingleLanguagePair(); boolean hasPivotLanguage(LanguageDirection direction); LanguageBridge getLanguageBridge(LanguageDirection direction); LanguageDirection map(LanguageDirection pair); LanguageDirection mapIgnoringDirection(LanguageDirection pair); @Override String toString(); }
LanguageIndex { public LanguageDirection map(LanguageDirection pair) { return mappingCache.computeIfAbsent(pair, this::search); } private  LanguageIndex(Map<SimpleLanguageDirection, List<LanguageDirection>> index, Map<String, List<LanguageRule>> rules, Map<LanguageDirection, LanguageBridge> pivots); Set<LanguageDirection> getLanguages(); int size(); LanguageDirection asSingleLanguagePair(); boolean hasPivotLanguage(LanguageDirection direction); LanguageBridge getLanguageBridge(LanguageDirection direction); LanguageDirection map(LanguageDirection pair); LanguageDirection mapIgnoringDirection(LanguageDirection pair); @Override String toString();  }