33import com .google .common .base .Strings ;
44import com .google .common .collect .Sets ;
55import org .jetbrains .annotations .ApiStatus ;
6+ import org .jetbrains .annotations .Contract ;
67import org .jetbrains .annotations .NotNull ;
78import org .jetbrains .annotations .Nullable ;
89import org .jetbrains .annotations .Unmodifiable ;
@@ -33,15 +34,15 @@ private StringFormatter() {
3334 * @param list the list of strings to join. If the list is empty, an empty string is returned.
3435 * @return the concatenated string
3536 */
36- public static @ NotNull String joinAnd (List <String > list ) {
37+ public static @ NotNull String joinAnd (@ Nullable List <String > list ) {
3738 return join (list , ", " , " and " );
3839 }
3940
40- public static @ NotNull String join (Collection list , String separator ) {
41+ public static @ NotNull String join (@ Nullable Collection <?> list , @ NotNull String separator ) {
4142 if (list == null || list .isEmpty ()) {
4243 return "" ;
4344 }
44- return list .stream ().map (String ::valueOf ).collect (Collectors .joining (separator )). toString () ;
45+ return list .stream ().map (String ::valueOf ).collect (Collectors .joining (separator ));
4546 }
4647
4748 /**
@@ -53,7 +54,7 @@ private StringFormatter() {
5354 * @param lastSeparator the separator to use before the last element. For example, " and ".
5455 * @return the concatenated string
5556 */
56- public static @ NotNull String join (List <String > list , String separator , String lastSeparator ) {
57+ public static @ NotNull String join (@ Nullable List <String > list , @ NotNull String separator , @ NotNull String lastSeparator ) {
5758 if (list == null || list .isEmpty ()) {
5859 return "" ;
5960 }
@@ -116,7 +117,7 @@ public static Collection<String> addOnToCommaSeparated(@Nullable String input, @
116117 * @param args The args to parse
117118 * @return The parsed args
118119 */
119- public static Collection <String > parseQuotesInArgs (String [] args ) {
120+ public static @ NotNull Collection <String > parseQuotesInArgs (@ NotNull String [] args ) {
120121 List <String > result = new ArrayList <>(args .length );
121122 StringBuilder current = new StringBuilder ();
122123 boolean inQuotes = false ;
@@ -161,8 +162,9 @@ public static Collection<String> parseQuotesInArgs(String[] args) {
161162 * @param input The string to add quotes to
162163 * @return The quoted string
163164 */
164- public static String quoteMultiWordString (String input ) {
165- return input .contains (" " ) ? "\" " + input + "\" " : input ;
165+ @ Contract ("null -> null" )
166+ public static @ Nullable String quoteMultiWordString (@ Nullable String input ) {
167+ return input != null && input .contains (" " ) ? "\" " + input + "\" " : input ;
166168 }
167169
168170 /**
0 commit comments