MCPcopy
hub / github.com/google/guava / onPatternInternal

Method onPatternInternal

guava/src/com/google/common/base/Splitter.java:211–232  ·  view source on GitHub ↗

Internal utility; see {@link #on(Pattern)} instead.

(CommonPattern separatorPattern)

Source from the content-addressed store, hash-verified

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)

Callers 2

onMethod · 0.95
onPatternMethod · 0.95

Calls 3

checkArgumentMethod · 0.45
matchesMethod · 0.45
matcherMethod · 0.45

Tested by

no test coverage detected