@Test public void ruledLanguageMonodirectional() { LanguageIndex index = new LanguageIndex.Builder() .add(lp("en es-ES")) .add(lp("en es-MX")) .addRule(p("es * *"), l("es-MX")) .build(); assertEquals(lp("en es-MX"), index.map(lp("en es"))); assertEquals(lp("en es-ES"), index.map(lp("en es-ES"))); assertEquals(lp("en es-MX"), index.map(lp("en es-MX"))); assertEquals(lp("en es-MX"), index.map(lp("en es-CO"))); assertEquals(lp("en es-MX"), index.map(lp("en-US es-CO"))); assertEquals(lp("en es-MX"), index.map(lp("en-US-x-Custom es-CO-x-Custom"))); assertNull(index.map(lp("es en"))); assertNull(index.map(lp("es-ES en"))); assertNull(index.map(lp("es-MX en"))); assertNull(index.map(lp("es-CO en"))); assertNull(index.map(lp("es-CO en-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();  }