VerbDeinflection { public static Deinflections deinflect(final String japanese) { final Deinflections result = new Deinflections(); result.deinflections=new ArrayList<Deinflection>(); result.deinflectedVerbs = new HashSet<String>(); Set<String> finalDeinflect = new HashSet<String>(); result.deinflectedVerbs.add(RomanizationEnum.NihonShiki.toRomaji(japanese).trim()); for (final AbstractDeinflector deinflector : DEINFLECTORS) { final Set<String> newResult = new HashSet<String>(result.deinflectedVerbs); for (final String romaji : result.deinflectedVerbs) { final Set<String> deinflected = deinflector.deinflect(romaji); if (deinflected != null && !deinflected.isEmpty()) { newResult.remove(romaji); if (deinflector.stopIfMatch()) { finalDeinflect.addAll(deinflected); } else { newResult.addAll(deinflected); } result.deinflections.add(new Deinflection(romaji, deinflector.getForm(), deinflected.toArray(new String[0]))); } } result.deinflectedVerbs = newResult; } result.deinflectedVerbs.addAll(finalDeinflect); return result; } private  VerbDeinflection(); static Deinflections deinflect(final String japanese); static Deinflections searchJpDeinflected(final String verb, final RomanizationEnum romanization);  }
@Test public void testNonVerb() { assertArrayEqualsNoOrder(VerbDeinflection.deinflect("kirei").deinflectedVerbs, Arrays.asList("kirei")); }