@Test public void shouldUndernalizeAllCamelcaseCharacters() { String base = "C"; assertThat(config.nameFor(base), is(equalTo("c"))); }
public String nameFor(String name) { if(name.length()==1) { return name.toLowerCase(); } StringBuilder content = new StringBuilder(); content.append(Character.toLowerCase(name.charAt(0))); for(int i=1;i<name.length();i++) { char c = name.charAt(i); if(Character.isUpperCase(c)) { content.append('_'); content.append(Character.toLowerCase(c)); } else { content.append(c); } } return content.toString(); }
DefaultXMLConfiguration implements XMLConfiguration { public String nameFor(String name) { if(name.length()==1) { return name.toLowerCase(); } StringBuilder content = new StringBuilder(); content.append(Character.toLowerCase(name.charAt(0))); for(int i=1;i<name.length();i++) { char c = name.charAt(i); if(Character.isUpperCase(c)) { content.append('_'); content.append(Character.toLowerCase(c)); } else { content.append(c); } } return content.toString(); } }
DefaultXMLConfiguration implements XMLConfiguration { public String nameFor(String name) { if(name.length()==1) { return name.toLowerCase(); } StringBuilder content = new StringBuilder(); content.append(Character.toLowerCase(name.charAt(0))); for(int i=1;i<name.length();i++) { char c = name.charAt(i); if(Character.isUpperCase(c)) { content.append('_'); content.append(Character.toLowerCase(c)); } else { content.append(c); } } return content.toString(); }  }
DefaultXMLConfiguration implements XMLConfiguration { public String nameFor(String name) { if(name.length()==1) { return name.toLowerCase(); } StringBuilder content = new StringBuilder(); content.append(Character.toLowerCase(name.charAt(0))); for(int i=1;i<name.length();i++) { char c = name.charAt(i); if(Character.isUpperCase(c)) { content.append('_'); content.append(Character.toLowerCase(c)); } else { content.append(c); } } return content.toString(); }  String nameFor(String name); }
DefaultXMLConfiguration implements XMLConfiguration { public String nameFor(String name) { if(name.length()==1) { return name.toLowerCase(); } StringBuilder content = new StringBuilder(); content.append(Character.toLowerCase(name.charAt(0))); for(int i=1;i<name.length();i++) { char c = name.charAt(i); if(Character.isUpperCase(c)) { content.append('_'); content.append(Character.toLowerCase(c)); } else { content.append(c); } } return content.toString(); }  String nameFor(String name);  }