DefaultSimilarNamesPolicy extends AbstractPolicy implements SimilarNamesPolicy { String clean(String string) { String clean = string.toUpperCase(); clean = clean.replaceAll("(\\bSTREET\\b|\\bST\\b)", ""); clean = clean.replaceAll("(\\bAVENUE\\b|\\bAVE\\b)", ""); clean = clean.replaceAll("(\\bBOULEVARD\\b|\\bBLVD\\b|\\bBL\\b)", ""); clean = clean.replaceAll("(\\bPLACE\\b|\\bPL\\b)", ""); clean = clean.replaceAll("(\\bNORTH\\b|\\bSOUTH\\b|\\bEAST\\b|\\bWEST\\b)", ""); clean = clean.replaceAll("(\\bPARKWAY\\b|\\bPKWY\\b)", ""); clean = clean.trim(); if (clean.isEmpty()) { return string; } return clean; }  int getSimilarNamesDistance(); void setSimilarNamesDistance(int similarNamesDistance); @Override boolean isSimilarName(String original, String proposed); @Override String getDescription(); @Override int hashCode(); @Override boolean equals(Object obj); static final int DEFAULT_SIMILAR_NAMES_DISTANCE; }
@Test public void testClean() { assertThat(policy.clean("")).isEqualTo(""); assertThat(policy.clean(" ")).isEqualTo(" "); assertThat(policy.clean("a")).isEqualTo("A"); assertThat(policy.clean("a ")).isEqualTo("A"); assertThat(policy.clean(" a ")).isEqualTo("A"); assertThat(policy.clean(" ave a ")).isEqualTo("A"); assertThat(policy.clean("St Marks")).isEqualTo("MARKS"); }