@@ -502,32 +502,26 @@ public static String[] toStringArray(Collection<String> collection) {
502502 }
503503
504504 public static Set <String > splitStringByCommaToSet (final String s ) {
505- return splitStringToSet (s , ',' , false );
505+ return splitStringToSet (s , ',' );
506506 }
507507
508508 public static String [] splitStringByCommaToArray (final String s ) {
509509 if (s == null || s .isEmpty ()) return Strings .EMPTY_ARRAY ;
510510 else return s .split ("," );
511511 }
512512
513- public static Set <String > splitStringByCommaAndTrim (final String s ) {
514- return splitStringToSet (s , ',' , true );
515- }
516-
517513 /**
518514 * A convenience method for splitting a delimited string into
519- * a set, while having the option to trim the whitespace after
520- * the delimiter. Trimming allows splitting strings like "A, B, C"
515+ * a set, and also trimming any whitespace found after the
516+ * delimiter. Trimming allows splitting strings like "A, B, C"
521517 * into ["A","B","C"] instead of ["A", " B", " C"]. The trimming
522- * will *only* apply if the delimiter is not a whitespace character,
523- * even if the option is set to true.
518+ * will *only* apply if the delimiter is not a whitespace character.
524519 *
525520 * @param s the string to split
526521 * @param c the delimiter to split on
527- * @param trim whether or not to trim the whitespace after the delimiter
528522 * @return the set of split strings
529523 */
530- public static Set <String > splitStringToSet (final String s , final char c , final boolean trim ) {
524+ public static Set <String > splitStringToSet (final String s , final char c ) {
531525 if (s == null || s .isEmpty ()) {
532526 return Collections .emptySet ();
533527 }
@@ -539,13 +533,13 @@ public static Set<String> splitStringToSet(final String s, final char c, final b
539533 }
540534 }
541535 final Set <String > result = new HashSet <>(count );
542- final boolean doTrim = trim & Character .isWhitespace (c ) == false ;
536+ final boolean doTrim = Character .isWhitespace (c ) == false ;
543537 final int len = chars .length ;
544538 int start = 0 ; // starting index in chars of the current substring.
545539 int pos = 0 ; // current index in chars.
546540 for (; pos < len ; pos ++) {
547- // if the option is set and the delimiter is a non-whitespace character, and we
548- // have whitespace after the comma, ignore the whitespace
541+ // if the delimiter is a non-whitespace character and we
542+ // have whitespace after the comma, skip over the whitespace
549543 if (doTrim && start == pos && Character .isWhitespace (chars [pos ])) {
550544 start ++;
551545 continue ;
0 commit comments