Inflector { public static String underscore(String camelCased) { List<String> parts = Inflector.split(camelCased); for (int i = 0; i < parts.size(); i++) { parts.set(i, parts.get(i).toLowerCase()); } return Join.underscore(parts); } private  Inflector(); static String underscore(String camelCased); static String camelize(String s); static String humanize(String camelCased); static String capitalize(String str); static String uncapitalize(String str);  }
@Test public void testUnderscore() { Assert.assertEquals("test_one_two", Inflector.underscore("testOneTwo")); Assert.assertEquals("test_one_two_1", Inflector.underscore("testOneTwo1")); Assert.assertEquals("test_one_two_a", Inflector.underscore("testOneTwoA")); Assert.assertEquals("test_one_two", Inflector.underscore("TestOneTwo")); Assert.assertEquals("test_one_two", Inflector.underscore("test_one_two")); Assert.assertEquals("test_one_two", Inflector.underscore("TEST_ONE_TWO")); }