本文整理了Java中com.netflix.spectator.impl.matcher.ZeroOrMoreMatcher.<init>()
方法的一些代码示例,展示了ZeroOrMoreMatcher.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroOrMoreMatcher.<init>()
方法的具体详情如下:
包路径:com.netflix.spectator.impl.matcher.ZeroOrMoreMatcher
类名称:ZeroOrMoreMatcher
方法名:<init>
[英]Create a new instance.
[中]创建一个新实例。
代码示例来源:origin: Netflix/spectator
@Override
public Matcher mergeNext(Matcher after) {
if (after instanceof TrueMatcher) {
return this;
}
Matcher m = (next instanceof TrueMatcher) ? after : SeqMatcher.create(next, after);
return new ZeroOrMoreMatcher(repeated, m);
}
代码示例来源:origin: Netflix/spectator
@Override
public Matcher rewriteEnd(Function<Matcher, Matcher> f) {
return f.apply(new ZeroOrMoreMatcher(repeated, next.rewriteEnd(f)));
}
代码示例来源:origin: com.netflix.spectator/spectator-api
@Override
public Matcher mergeNext(Matcher after) {
if (after instanceof TrueMatcher) {
return this;
}
Matcher m = (next instanceof TrueMatcher) ? after : SeqMatcher.create(next, after);
return new ZeroOrMoreMatcher(repeated, m);
}
代码示例来源:origin: com.netflix.spectator/spectator-api
@Override
public Matcher rewriteEnd(Function<Matcher, Matcher> f) {
return f.apply(new ZeroOrMoreMatcher(repeated, next.rewriteEnd(f)));
}
代码示例来源:origin: Netflix/spectator
@Override
public Matcher rewrite(Function<Matcher, Matcher> f) {
return f.apply(new ZeroOrMoreMatcher(repeated.rewrite(f), next.rewrite(f)));
}
代码示例来源:origin: com.netflix.spectator/spectator-api
@Override
public Matcher rewrite(Function<Matcher, Matcher> f) {
return f.apply(new ZeroOrMoreMatcher(repeated.rewrite(f), next.rewrite(f)));
}
代码示例来源:origin: Netflix/spectator
@Test
public void removeSequentialMatchAny() {
Matcher input = new ZeroOrMoreMatcher(
AnyMatcher.INSTANCE,
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE)
);
Matcher expected = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE);
Assertions.assertEquals(expected, Optimizer.removeSequentialMatchAny(input));
}
代码示例来源:origin: Netflix/spectator
/**
* Get the prefix matcher. This is similar to {@link #head(Matcher)} except that it can
* reach into character sequences as well as higher level sequences.
*/
static Matcher getPrefix(Matcher matcher) {
if (matcher instanceof SeqMatcher) {
List<Matcher> ms = matcher.<SeqMatcher>as().matchers();
return ms.get(0);
} else if (matcher instanceof ZeroOrMoreMatcher) {
ZeroOrMoreMatcher zm = matcher.as();
return new ZeroOrMoreMatcher(zm.repeated(), TrueMatcher.INSTANCE);
} else if (matcher instanceof CharSeqMatcher) {
String pattern = matcher.<CharSeqMatcher>as().pattern();
return pattern.isEmpty() ? null : new CharSeqMatcher(pattern.charAt(0));
} else {
return matcher;
}
}
代码示例来源:origin: Netflix/spectator
@Test
public void convertRepeatedAnyCharSeqToIndexOf() {
Matcher input = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create(
new CharSeqMatcher("abc"),
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create(
new CharSeqMatcher("def"),
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, TrueMatcher.INSTANCE)
))
));
Matcher expected = SeqMatcher.create(
new IndexOfMatcher(
"abc",
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create(
new CharSeqMatcher("def"),
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, TrueMatcher.INSTANCE)
))
)
);
Assertions.assertEquals(expected, Optimizer.convertRepeatedAnyCharSeqToIndexOf(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void removeStartFollowedByMatchAny() {
Matcher input = SeqMatcher.create(
StartMatcher.INSTANCE,
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE)
);
Matcher expected = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE);
Assertions.assertEquals(expected, Optimizer.removeStartFollowedByMatchAny(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void extractPrefixFromOr() {
Matcher a = new CharSeqMatcher("a");
Matcher b = new CharSeqMatcher("b");
Matcher input = OrMatcher.create(
new ZeroOrMoreMatcher(a, AnyMatcher.INSTANCE),
new ZeroOrMoreMatcher(a, a),
new ZeroOrMoreMatcher(a, b)
);
Matcher expected = SeqMatcher.create(
new ZeroOrMoreMatcher(a, TrueMatcher.INSTANCE),
OrMatcher.create(AnyMatcher.INSTANCE, a, b)
);
Assertions.assertEquals(expected, Optimizer.extractPrefixFromOr(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void inlineMatchAnyPrecedingOr() {
Matcher a = new CharSeqMatcher("a");
Matcher b = new CharSeqMatcher("b");
Matcher input = new ZeroOrMoreMatcher(
AnyMatcher.INSTANCE,
OrMatcher.create(a, b)
);
Matcher expected = OrMatcher.create(
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, a),
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, b)
);
Assertions.assertEquals(expected, Optimizer.inlineMatchAnyPrecedingOr(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void zeroOrMoreFalse_Next() {
Matcher input = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, FalseMatcher.INSTANCE);
Matcher expected = FalseMatcher.INSTANCE;
Assertions.assertEquals(expected, Optimizer.zeroOrMoreFalse(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void zeroOrMoreFalse_Repeated() {
Matcher input = new ZeroOrMoreMatcher(FalseMatcher.INSTANCE, AnyMatcher.INSTANCE);
Matcher expected = AnyMatcher.INSTANCE;
Assertions.assertEquals(expected, Optimizer.zeroOrMoreFalse(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void removeTrailingMatchAny() {
Matcher input = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, EndMatcher.INSTANCE);
Matcher expected = TrueMatcher.INSTANCE;
Assertions.assertEquals(expected, Optimizer.removeTrailingMatchAny(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void removeRepeatedStart() {
Matcher input = new ZeroOrMoreMatcher(StartMatcher.INSTANCE, AnyMatcher.INSTANCE);
Matcher expected = AnyMatcher.INSTANCE;
Assertions.assertEquals(expected, Optimizer.removeRepeatedStart(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void zeroOrMoreMergeNext() {
Matcher input = SeqMatcher.create(
AnyMatcher.INSTANCE,
new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE),
AnyMatcher.INSTANCE
);
Matcher expected = SeqMatcher.create(
AnyMatcher.INSTANCE,
new ZeroOrMoreMatcher(
AnyMatcher.INSTANCE,
SeqMatcher.create(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE))
);
Assertions.assertEquals(expected, Optimizer.mergeNext(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void removeMatchAnyFollowedByStart() {
Matcher input = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create(
StartMatcher.INSTANCE,
AnyMatcher.INSTANCE
));
Matcher expected = SeqMatcher.create(StartMatcher.INSTANCE, AnyMatcher.INSTANCE);
Assertions.assertEquals(expected, Optimizer.removeMatchAnyFollowedByStart(input));
}
代码示例来源:origin: Netflix/spectator
@Test
public void optimizeOrIndexOf() {
PatternMatcher actual = PatternMatcher.compile("^.*abc.*|.*def.*|.*ghi*.");
PatternMatcher expected = OrMatcher.create(
new IndexOfMatcher("abc", TrueMatcher.INSTANCE),
new IndexOfMatcher("def", TrueMatcher.INSTANCE),
new IndexOfMatcher(
"gh",
new ZeroOrMoreMatcher(new CharSeqMatcher("i"), AnyMatcher.INSTANCE)
)
);
Assertions.assertEquals(expected, actual);
}
代码示例来源:origin: Netflix/spectator
@Test
public void removeMatchAnyFollowedByIndexOf() {
Matcher input = new ZeroOrMoreMatcher(
AnyMatcher.INSTANCE,
new IndexOfMatcher("foo", TrueMatcher.INSTANCE));
Matcher expected = new IndexOfMatcher("foo", TrueMatcher.INSTANCE);
Assertions.assertEquals(expected, Optimizer.removeMatchAnyFollowedByIndexOf(input));
}
内容来源于网络,如有侵权,请联系作者删除!