@Test public void shouldFindRoots() { final String rootStr = "root1"; final Collection<? extends Root> roots = finder.findRootsForPartialInput(new TurkishSequence(rootStr), null); assertThat(roots, hasSize(2)); assertThat(roots, (Matcher) hasItem(root1_1)); assertThat(roots, (Matcher) hasItem(root1_2)); }
@Override public Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input) { final Collection<? extends Root> roots = this.rootMap.get(partialInput.getUnderlyingString()); if (Character.isUpperCase(partialInput.charAt(0).getCharValue())) { final ArrayList<Root> result = new ArrayList<Root>(); final String uncapitalized = TurkishAlphabet.uncapitalize(partialInput.getUnderlyingString()); final Collection<? extends Root> lowerCaseRoots = this.rootMap.get(uncapitalized); result.addAll(roots); result.addAll(lowerCaseRoots); if (CollectionUtils.isEmpty(result)) return Collections.emptyList(); else return result; } else { if (CollectionUtils.isEmpty(roots)) return Collections.emptyList(); else return roots; } }
DictionaryRootFinder implements RootFinder { @Override public Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input) { final Collection<? extends Root> roots = this.rootMap.get(partialInput.getUnderlyingString()); if (Character.isUpperCase(partialInput.charAt(0).getCharValue())) { final ArrayList<Root> result = new ArrayList<Root>(); final String uncapitalized = TurkishAlphabet.uncapitalize(partialInput.getUnderlyingString()); final Collection<? extends Root> lowerCaseRoots = this.rootMap.get(uncapitalized); result.addAll(roots); result.addAll(lowerCaseRoots); if (CollectionUtils.isEmpty(result)) return Collections.emptyList(); else return result; } else { if (CollectionUtils.isEmpty(roots)) return Collections.emptyList(); else return roots; } } }
DictionaryRootFinder implements RootFinder { @Override public Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input) { final Collection<? extends Root> roots = this.rootMap.get(partialInput.getUnderlyingString()); if (Character.isUpperCase(partialInput.charAt(0).getCharValue())) { final ArrayList<Root> result = new ArrayList<Root>(); final String uncapitalized = TurkishAlphabet.uncapitalize(partialInput.getUnderlyingString()); final Collection<? extends Root> lowerCaseRoots = this.rootMap.get(uncapitalized); result.addAll(roots); result.addAll(lowerCaseRoots); if (CollectionUtils.isEmpty(result)) return Collections.emptyList(); else return result; } else { if (CollectionUtils.isEmpty(roots)) return Collections.emptyList(); else return roots; } } DictionaryRootFinder(Multimap<String, ? extends Root> rootMap); }
DictionaryRootFinder implements RootFinder { @Override public Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input) { final Collection<? extends Root> roots = this.rootMap.get(partialInput.getUnderlyingString()); if (Character.isUpperCase(partialInput.charAt(0).getCharValue())) { final ArrayList<Root> result = new ArrayList<Root>(); final String uncapitalized = TurkishAlphabet.uncapitalize(partialInput.getUnderlyingString()); final Collection<? extends Root> lowerCaseRoots = this.rootMap.get(uncapitalized); result.addAll(roots); result.addAll(lowerCaseRoots); if (CollectionUtils.isEmpty(result)) return Collections.emptyList(); else return result; } else { if (CollectionUtils.isEmpty(roots)) return Collections.emptyList(); else return roots; } } DictionaryRootFinder(Multimap<String, ? extends Root> rootMap); @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input); }
DictionaryRootFinder implements RootFinder { @Override public Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input) { final Collection<? extends Root> roots = this.rootMap.get(partialInput.getUnderlyingString()); if (Character.isUpperCase(partialInput.charAt(0).getCharValue())) { final ArrayList<Root> result = new ArrayList<Root>(); final String uncapitalized = TurkishAlphabet.uncapitalize(partialInput.getUnderlyingString()); final Collection<? extends Root> lowerCaseRoots = this.rootMap.get(uncapitalized); result.addAll(roots); result.addAll(lowerCaseRoots); if (CollectionUtils.isEmpty(result)) return Collections.emptyList(); else return result; } else { if (CollectionUtils.isEmpty(roots)) return Collections.emptyList(); else return roots; } } DictionaryRootFinder(Multimap<String, ? extends Root> rootMap); @Override boolean handles(TurkishSequence partialInput, TurkishSequence input); @Override Collection<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence _input);  }