Inflector { public String underscore( String camelCaseWord, char... delimiterChars ) { if (camelCaseWord == null) return null; String result = camelCaseWord.trim(); if (result.length() == 0) return ""; result = result.replaceAll("([A-Z]+)([A-Z][a-z])", "$1_$2"); result = result.replaceAll("([a-z\\d])([A-Z])", "$1_$2"); result = result.replace('-', '_'); if (delimiterChars != null) { for (char delimiterChar : delimiterChars) { result = result.replace(delimiterChar, '_'); } } return result.toLowerCase(); } Inflector(); protected  Inflector( Inflector original ); static final Inflector getInstance(); @Override Inflector clone(); String pluralize( Object word ); String pluralize( Object word,
                             int count ); String singularize( Object word ); String lowerCamelCase( String lowerCaseAndUnderscoredWord,
                                  char... delimiterChars ); String upperCamelCase( String lowerCaseAndUnderscoredWord,
                                  char... delimiterChars ); String camelCase( String lowerCaseAndUnderscoredWord,
                             boolean uppercaseFirstLetter,
                             char... delimiterChars ); String underscore( String camelCaseWord,
                              char... delimiterChars ); String capitalize( String words ); String humanize( String lowerCaseAndUnderscoredWords,
                            String... removableTokens ); String titleCase( String words,
                             String... removableTokens ); String ordinalize( int number ); boolean isUncountable( String word ); Set<String> getUncountables(); void addPluralize( String rule,
                              String replacement ); void addSingularize( String rule,
                                String replacement ); void addIrregular( String singular,
                              String plural ); void addUncountable( String... words ); void clear();  }
@Test public void shouldConvertToUnderscore() { underscore("activeRecord", "active_record"); underscore("ActiveRecord", "active_record"); underscore("ACTIVERecord", "active_record"); underscore("firstName", "first_name"); underscore("FirstName", "first_name"); underscore("name", "name"); underscore("The.firstName", "the_first_name", '.'); }