@Test public void addQuotesIfNecessary () { assertEquals("abc", StringUtils.addQuotesIfNecessary("abc")); assertEquals("\"ab cd\"", StringUtils.addQuotesIfNecessary("ab cd")); assertEquals("\"ab cd\"", StringUtils.addQuotesIfNecessary("\"ab cd\"")); }
public static String addQuotesIfNecessary (String string) { if (!string.contains(" ")) return string; StringBuilder sb = new StringBuilder(); if (!string.startsWith("\"")) sb.append("\""); sb.append(string); if (!string.endsWith("\"")) sb.append("\""); return sb.toString(); }
StringUtils { public static String addQuotesIfNecessary (String string) { if (!string.contains(" ")) return string; StringBuilder sb = new StringBuilder(); if (!string.startsWith("\"")) sb.append("\""); sb.append(string); if (!string.endsWith("\"")) sb.append("\""); return sb.toString(); } }
StringUtils { public static String addQuotesIfNecessary (String string) { if (!string.contains(" ")) return string; StringBuilder sb = new StringBuilder(); if (!string.startsWith("\"")) sb.append("\""); sb.append(string); if (!string.endsWith("\"")) sb.append("\""); return sb.toString(); } private  StringUtils(); }
StringUtils { public static String addQuotesIfNecessary (String string) { if (!string.contains(" ")) return string; StringBuilder sb = new StringBuilder(); if (!string.startsWith("\"")) sb.append("\""); sb.append(string); if (!string.endsWith("\"")) sb.append("\""); return sb.toString(); } private  StringUtils(); static String addQuotesIfNecessary(String string); static String generateRandomString(int length); static String convertCamelCaseToSentence(String camelCase); static String trimSpaces(String original); }
StringUtils { public static String addQuotesIfNecessary (String string) { if (!string.contains(" ")) return string; StringBuilder sb = new StringBuilder(); if (!string.startsWith("\"")) sb.append("\""); sb.append(string); if (!string.endsWith("\"")) sb.append("\""); return sb.toString(); } private  StringUtils(); static String addQuotesIfNecessary(String string); static String generateRandomString(int length); static String convertCamelCaseToSentence(String camelCase); static String trimSpaces(String original);  }