@Test public void testToCamelCase() { Assert.assertNull(StrKit.toCamelCase(null)); Assert.assertEquals("a\'b\'c", StrKit.toCamelCase("a\'b\'c")); Assert.assertEquals("fooBar", StrKit.toCamelCase("foo_bar")); }
public static String toCamelCase(String name) { if (name == null) { return null; } if (name.contains(UNDERLINE)) { name = name.toLowerCase(); StringBuilder sb = new StringBuilder(name.length()); boolean upperCase = false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c == '_') { upperCase = true; } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; } else { sb.append(c); } } return sb.toString(); } else { return name; } }
StrKit { public static String toCamelCase(String name) { if (name == null) { return null; } if (name.contains(UNDERLINE)) { name = name.toLowerCase(); StringBuilder sb = new StringBuilder(name.length()); boolean upperCase = false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c == '_') { upperCase = true; } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; } else { sb.append(c); } } return sb.toString(); } else { return name; } } }
StrKit { public static String toCamelCase(String name) { if (name == null) { return null; } if (name.contains(UNDERLINE)) { name = name.toLowerCase(); StringBuilder sb = new StringBuilder(name.length()); boolean upperCase = false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c == '_') { upperCase = true; } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; } else { sb.append(c); } } return sb.toString(); } else { return name; } }  }
StrKit { public static String toCamelCase(String name) { if (name == null) { return null; } if (name.contains(UNDERLINE)) { name = name.toLowerCase(); StringBuilder sb = new StringBuilder(name.length()); boolean upperCase = false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c == '_') { upperCase = true; } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; } else { sb.append(c); } } return sb.toString(); } else { return name; } }  static String firstCharToLowerCase(String str); static String firstCharToUpperCase(String str); static boolean isEmpty(String str); static boolean isNotEmpty(String str); static String nullToEmpty(String str); static String nullToDefault(String str, String defaultStr); static String toUnderlineCase(String camelCaseStr); static String toCamelCase(String name); }
StrKit { public static String toCamelCase(String name) { if (name == null) { return null; } if (name.contains(UNDERLINE)) { name = name.toLowerCase(); StringBuilder sb = new StringBuilder(name.length()); boolean upperCase = false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c == '_') { upperCase = true; } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; } else { sb.append(c); } } return sb.toString(); } else { return name; } }  static String firstCharToLowerCase(String str); static String firstCharToUpperCase(String str); static boolean isEmpty(String str); static boolean isNotEmpty(String str); static String nullToEmpty(String str); static String nullToDefault(String str, String defaultStr); static String toUnderlineCase(String camelCaseStr); static String toCamelCase(String name); static final String SPACE; static final String DOT; static final String SLASH; static final String BACKSLASH; static final String EMPTY; static final String CRLF; static final String NEWLINE; static final String UNDERLINE; static final String COMMA; static final String HTML_NBSP; static final String HTML_AMP; static final String HTML_QUOTE; static final String HTML_LT; static final String HTML_GT; static final String EMPTY_JSON; }