@Test public void shouldReturnCommaSeparatedList(){ ArrayList<String> listOfStrings = new ArrayList<String>() {{ add("Patient"); add("Registration"); add("New Tag"); }}; String commaSeparatedValues = StringUtils.getCommaSeparatedStringFromList(listOfStrings); assertThat(commaSeparatedValues, is("Patient,Registration,New Tag")); }
public static String getCommaSeparatedStringFromList(final List<String> values){ if(values == null){ return ""; } StringBuilder builder = new StringBuilder(); for (String next : values) { builder.append(next).append(","); } String commaSeparated = builder.toString(); return commaSeparated.substring(0, commaSeparated.length() - 1); }
StringUtils { public static String getCommaSeparatedStringFromList(final List<String> values){ if(values == null){ return ""; } StringBuilder builder = new StringBuilder(); for (String next : values) { builder.append(next).append(","); } String commaSeparated = builder.toString(); return commaSeparated.substring(0, commaSeparated.length() - 1); } }
StringUtils { public static String getCommaSeparatedStringFromList(final List<String> values){ if(values == null){ return ""; } StringBuilder builder = new StringBuilder(); for (String next : values) { builder.append(next).append(","); } String commaSeparated = builder.toString(); return commaSeparated.substring(0, commaSeparated.length() - 1); }  }
StringUtils { public static String getCommaSeparatedStringFromList(final List<String> values){ if(values == null){ return ""; } StringBuilder builder = new StringBuilder(); for (String next : values) { builder.append(next).append(","); } String commaSeparated = builder.toString(); return commaSeparated.substring(0, commaSeparated.length() - 1); }  static String getCommaSeparatedStringFromList(final List<String> values); static List<String> getListFromCommaSeparatedString(String value); static boolean isEmpty(String string); static String defaultString(String string); static boolean equals(String str1, String str2); static boolean equalsIgnoreCase(String str1, String str2); static int nullSafeCompare(String str1, String str2); }
StringUtils { public static String getCommaSeparatedStringFromList(final List<String> values){ if(values == null){ return ""; } StringBuilder builder = new StringBuilder(); for (String next : values) { builder.append(next).append(","); } String commaSeparated = builder.toString(); return commaSeparated.substring(0, commaSeparated.length() - 1); }  static String getCommaSeparatedStringFromList(final List<String> values); static List<String> getListFromCommaSeparatedString(String value); static boolean isEmpty(String string); static String defaultString(String string); static boolean equals(String str1, String str2); static boolean equalsIgnoreCase(String str1, String str2); static int nullSafeCompare(String str1, String str2); static final String EMPTY; }