@Test public void testLookup_notFound() throws Exception { PluralFormDictinary dictinary = new PluralFormDictinary(); assertNull(dictinary.lookup("employee")); }
public String lookup(String word) { for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { Pattern pattern = entry.getKey(); Matcher matcher = pattern.matcher(word); if (!matcher.matches()) { continue; } matcher.reset(); StringBuffer buf = new StringBuffer(); String replacement = entry.getValue(); for (; matcher.find();) { matcher.appendReplacement(buf, replacement); if (matcher.hitEnd()) { break; } } matcher.appendTail(buf); return buf.toString(); } return null; }
PluralFormDictinary { public String lookup(String word) { for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { Pattern pattern = entry.getKey(); Matcher matcher = pattern.matcher(word); if (!matcher.matches()) { continue; } matcher.reset(); StringBuffer buf = new StringBuffer(); String replacement = entry.getValue(); for (; matcher.find();) { matcher.appendReplacement(buf, replacement); if (matcher.hitEnd()) { break; } } matcher.appendTail(buf); return buf.toString(); } return null; } }
PluralFormDictinary { public String lookup(String word) { for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { Pattern pattern = entry.getKey(); Matcher matcher = pattern.matcher(word); if (!matcher.matches()) { continue; } matcher.reset(); StringBuffer buf = new StringBuffer(); String replacement = entry.getValue(); for (; matcher.find();) { matcher.appendReplacement(buf, replacement); if (matcher.hitEnd()) { break; } } matcher.appendTail(buf); return buf.toString(); } return null; } PluralFormDictinary();  PluralFormDictinary(LinkedHashMap<String, String> dictinary); }
PluralFormDictinary { public String lookup(String word) { for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { Pattern pattern = entry.getKey(); Matcher matcher = pattern.matcher(word); if (!matcher.matches()) { continue; } matcher.reset(); StringBuffer buf = new StringBuffer(); String replacement = entry.getValue(); for (; matcher.find();) { matcher.appendReplacement(buf, replacement); if (matcher.hitEnd()) { break; } } matcher.appendTail(buf); return buf.toString(); } return null; } PluralFormDictinary();  PluralFormDictinary(LinkedHashMap<String, String> dictinary); String lookup(String word); }
PluralFormDictinary { public String lookup(String word) { for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { Pattern pattern = entry.getKey(); Matcher matcher = pattern.matcher(word); if (!matcher.matches()) { continue; } matcher.reset(); StringBuffer buf = new StringBuffer(); String replacement = entry.getValue(); for (; matcher.find();) { matcher.appendReplacement(buf, replacement); if (matcher.hitEnd()) { break; } } matcher.appendTail(buf); return buf.toString(); } return null; } PluralFormDictinary();  PluralFormDictinary(LinkedHashMap<String, String> dictinary); String lookup(String word);  }