HungarianNotation { public static String removeNotationFromSetterAndSetPrefix(String methodName) { if (methodName.matches("^set\\w+")) { String withoutSetPrefix = methodName.substring(3); if (Character.isLowerCase(withoutSetPrefix.charAt(0))) { return HungarianNotation.removeNotation(withoutSetPrefix); } else if (withoutSetPrefix.length() >= 2 && withoutSetPrefix.charAt(0) == 'M' && Character.isUpperCase(withoutSetPrefix.charAt(1))) { return Character.toLowerCase(withoutSetPrefix.charAt(1)) + withoutSetPrefix.substring(2); } return removeNotation(withoutSetPrefix); } return removeNotation(methodName); } private  HungarianNotation(); static String removeNotation(String name); static String removeNotationFromSetterAndSetPrefix(String methodName);  }
@Test public void removeSetter() { Assert.assertEquals("lastname", HungarianNotation.removeNotationFromSetterAndSetPrefix( "setmLastname")); Assert.assertEquals("lastname", HungarianNotation.removeNotationFromSetterAndSetPrefix( "setMLastname")); Assert.assertEquals("lastName", HungarianNotation.removeNotationFromSetterAndSetPrefix( "setMLastName")); Assert.assertEquals("foo", HungarianNotation.removeNotationFromSetterAndSetPrefix("mFoo")); Assert.assertEquals("Bar", HungarianNotation.removeNotationFromSetterAndSetPrefix("setBar")); Assert.assertEquals("asd", HungarianNotation.removeNotationFromSetterAndSetPrefix("asd")); Assert.assertEquals("Asd", HungarianNotation.removeNotationFromSetterAndSetPrefix("Asd")); Assert.assertEquals("B", HungarianNotation.removeNotationFromSetterAndSetPrefix("B")); Assert.assertEquals("c", HungarianNotation.removeNotationFromSetterAndSetPrefix("c")); }