Splits sequence into string components and makes them available through an Iterator, which may be lazily evaluated. If you want an eagerly computed List, use #splitToList(CharSequence). @param sequence the sequence of characters to split @return an iteration over the
(final CharSequence sequence)
| 375 | * @return an iteration over the segments split from the parameter. |
| 376 | */ |
| 377 | public Iterable<String> split(final CharSequence sequence) { |
| 378 | checkNotNull(sequence); |
| 379 | |
| 380 | return new Iterable<String>() { |
| 381 | @Override |
| 382 | public Iterator<String> iterator() { |
| 383 | return splittingIterator(sequence); |
| 384 | } |
| 385 | |
| 386 | @Override |
| 387 | public String toString() { |
| 388 | return Joiner.on(", ") |
| 389 | .appendTo(new StringBuilder().append('['), this) |
| 390 | .append(']') |
| 391 | .toString(); |
| 392 | } |
| 393 | }; |
| 394 | } |
| 395 | |
| 396 | private Iterator<String> splittingIterator(CharSequence sequence) { |
| 397 | return strategy.iterator(this, sequence); |
no test coverage detected