|
32 | 32 | import static java.lang.Character.isWhitespace; |
33 | 33 | import static java.lang.Character.toLowerCase; |
34 | 34 | import static java.lang.Character.toUpperCase; |
| 35 | +import static java.lang.String.valueOf; |
35 | 36 |
|
36 | 37 | /** |
37 | 38 | * The utilities class for {@link String} |
@@ -132,27 +133,7 @@ public static boolean isNotBlank(String value) { |
132 | 133 | */ |
133 | 134 | @Nonnull |
134 | 135 | public static String[] split(@Nullable String value, char delimiter) { |
135 | | - int length = length(value); |
136 | | - if (length < 1) { |
137 | | - return EMPTY_STRING_ARRAY; |
138 | | - } |
139 | | - |
140 | | - List<String> result = new ArrayList<>(); |
141 | | - |
142 | | - int startIndex = 0; |
143 | | - int endIndex; |
144 | | - |
145 | | - while ((endIndex = value.indexOf(delimiter, startIndex)) > -1) { |
146 | | - String part = value.substring(startIndex, endIndex); |
147 | | - result.add(part); |
148 | | - startIndex = endIndex + 1; |
149 | | - } |
150 | | - if (startIndex <= length) { |
151 | | - // Add rest of String, but not in case of empty input. |
152 | | - result.add(value.substring(startIndex)); |
153 | | - } |
154 | | - |
155 | | - return toStringArray(result); |
| 136 | + return split(value, valueOf(delimiter)); |
156 | 137 | } |
157 | 138 |
|
158 | 139 | /** |
@@ -852,7 +833,7 @@ public static String uncapitalize(String str) { |
852 | 833 | */ |
853 | 834 | @Nonnull |
854 | 835 | public static String[] toStringArray(@Nullable Collection<String> collection) { |
855 | | - return (!isEmpty(collection) ? collection.toArray(EMPTY_STRING_ARRAY) : EMPTY_STRING_ARRAY); |
| 836 | + return isEmpty(collection) ? EMPTY_STRING_ARRAY : collection.toArray(EMPTY_STRING_ARRAY); |
856 | 837 | } |
857 | 838 |
|
858 | 839 | static String changeFirstCharacter(String str, boolean capitalize) { |
|
0 commit comments