Internal utility; see {@link #on(Pattern)} instead.
(CommonPattern separatorPattern)
| 209 | |
| 210 | /** Internal utility; see {@link #on(Pattern)} instead. */ |
| 211 | static Splitter onPatternInternal(CommonPattern separatorPattern) { |
| 212 | checkArgument( |
| 213 | !separatorPattern.matcher("").matches(), |
| 214 | "The pattern may not match the empty string: %s", |
| 215 | separatorPattern); |
| 216 | |
| 217 | return new Splitter( |
| 218 | (splitter, toSplit) -> { |
| 219 | CommonMatcher matcher = separatorPattern.matcher(toSplit); |
| 220 | return new SplittingIterator(splitter, toSplit) { |
| 221 | @Override |
| 222 | public int separatorStart(int start) { |
| 223 | return matcher.find(start) ? matcher.start() : -1; |
| 224 | } |
| 225 | |
| 226 | @Override |
| 227 | public int separatorEnd(int separatorPosition) { |
| 228 | return matcher.end(); |
| 229 | } |
| 230 | }; |
| 231 | }); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Returns a splitter that considers any subsequence matching a given pattern (regular expression) |
no test coverage detected