String (String in) { final int inLen = in.length(); for (int i = 0; i < SINGULAR_STORE.size(); i+= 2) { final String lastPart = SINGULAR_STORE.get(i); final boolean wholeWord = Character.isUpperCase(lastPart.charAt(0)); final int endingOnly = lastPart.charAt(0) == '-' ? 1 : 0; final int len = lastPart.length(); if (inLen < len) continue; if (!in.regionMatches(true, inLen - len + endingOnly, lastPart, endingOnly, len - endingOnly)) continue; if (wholeWord && inLen != len && !Character.isUpperCase(in.charAt(inLen - len))) continue; String replacement = SINGULAR_STORE.get(i + 1); if (replacement.equals("!")) return null; boolean capitalizeFirst = !replacement.isEmpty() && Character.isUpperCase(in.charAt(inLen - len + endingOnly)); String pre = in.substring(0, inLen - len + endingOnly); String post = capitalizeFirst ? Character.toUpperCase(replacement.charAt(0)) + replacement.substring(1) : replacement; return pre + post; } return null; }