TextUtils { public static String getCommaDelimitedString( Collection<?> elements ) { if ( elements != null ) { return elements.stream().map( Object::toString ).collect( Collectors.joining( DELIMITER ) ); } return ""; }  static String htmlify( String text ); static String htmlLinks( String text ); static String htmlNewline( String text ); static List<String> getTokens( String string ); static String subString( String string, int beginIndex, int length ); static String removeLastOr( String string ); static String removeLastAnd( String string ); static String removeLastComma( String string ); static String removeLast( String string, String remove ); static String removeNewlines( String string ); static String trimEnd( String value, int length ); static String getString( String string, boolean emptyString ); static String join( List<T> list, String separator, T nullReplacement ); @SafeVarargs static String joinHyphen( T... elements ); static String getCommaDelimitedString( Collection<?> elements ); static String getCommaDelimitedString( Collection<?> elements, boolean delimitPrefix, boolean delimitSuffix ); static String getQuotedCommaDelimitedString( Collection<? extends Object> elements ); static boolean equalsNullSafe( String s1, String s2 ); static String valueOf( Boolean value ); static Boolean valueOf( String value ); static String lower( String string ); static String toString( String[] array, String separator ); static String toString( Object object ); static String emptyIfEqual( String string, String test ); static String emptyIfFalse( String string, boolean test ); static String appendTail( Matcher matcher, StringBuffer sb ); static String getPrettyClassName( Class<?> clazz ); static String getPrettyEnumName( Enum<?> enumeration ); static String getPrettyPropertyName( String property ); static String splitSafe( String string, String separator, int index ); static boolean containsAnyIgnoreCase( String string, Collection<String> searchStrings ); static Set<String> splitToArray( String value, String separator ); static String replaceFirst( String string, final String regex, final String replacement, final int occurrences ); static String replace( String string, String... symbolReplacementPairs ); static List<String> getOptions( String param ); static String createRegexFromGlob( String glob ); static final TextUtils INSTANCE; static final String EMPTY; static final String SPACE; static final String SEP; static final String LN; static final String SEMICOLON; }
@Test public void testGetCommaDelimitedString() { assertThat( TextUtils.getCommaDelimitedString( Arrays.asList( 1, 2, 3, 4, 5 ) ), is( "1, 2, 3, 4, 5" ) ); assertThat( TextUtils.getCommaDelimitedString( Collections.singletonList( 1 ) ), is( "1" ) ); assertThat( TextUtils.getCommaDelimitedString( null ), is( "" ) ); }