@Test public void simpleLanguageBidirectional() { LanguageIndex index = new LanguageIndex.Builder() .add(lp("en fr")) .add(lp("fr en")) .build(); assertEquals(lp("en fr"), index.map(lp("en fr"))); assertEquals(lp("en fr"), index.map(lp("en fr-FR"))); assertEquals(lp("en fr"), index.map(lp("en-GB fr"))); assertEquals(lp("en fr"), index.map(lp("en-GB fr-FR"))); assertEquals(lp("fr en"), index.map(lp("fr en"))); assertEquals(lp("fr en"), index.map(lp("fr-FR en"))); assertEquals(lp("fr en"), index.map(lp("fr en-GB"))); assertEquals(lp("fr en"), index.map(lp("fr-FR en-GB"))); }
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();  }