public static String enumerateCollection(final Collection<String> collection){
  if (collection == null) {
    return "";
  }
  final String[] elements=collection.toArray(new String[collection.size()]);
  String ret;
  if (elements.length == 0) {
    ret="";
  }
 else   if (elements.length == 1) {
    ret=quoteHash(elements[0]);
  }
 else   if (elements.length == 2) {
    ret=quoteHash(elements[0]) + " and " + quoteHash(elements[1]);
  }
 else {
    final StringBuilder sb=new StringBuilder();
    for (int i=0; i < elements.length - 1; i++) {
      sb.append(quoteHash(elements[i]) + ", ");
    }
    sb.append("and " + quoteHash(elements[elements.length - 1]));
    ret=sb.toString();
  }
  return replaceInternalByDisplayNames(ret);
}

public static String enumerateCollection ( final Collection < String > collection ) { if ( collection == null ) { return "" ; } final String [ ] elements = collection . toArray ( new String [ collection . size ( ) ] ) ; String ret ; if ( elements . length == 0 ) { ret = "" ; } else if ( elements . length == 1 ) { ret = quoteHash ( elements [ 0 ] ) ; } else if ( elements . length == 2 ) { ret = quoteHash ( elements [ 0 ] ) + " and " + quoteHash ( elements [ 1 ] ) ; } else { final StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < elements . length - 1 ; i ++ ) { sb . append ( quoteHash ( elements [ i ] ) + ", " ) ; } sb . append ( "and " + quoteHash ( elements [ elements . length - 1 ] ) ) ; ret = sb . toString ( ) ; } return replaceInternalByDisplayNames ( ret ) ; }
helper function to nicely formulate an enumeration of a collection . < p > for example , for a collection containing the 3 elements x , y , z , returns the string " x , y , and z " .
