MCPcopy Create free account
hub / github.com/apache/calcite / TermRule

Class TermRule

core/src/test/java/org/apache/calcite/test/LintTest.java:466–486  ·  view source on GitHub ↗

A rule for defining valid patterns for terms.

Source from the content-addressed store, hash-verified

464 * A rule for defining valid patterns for terms.
465 */
466 private static final class TermRule {
467 private final Pattern termPattern;
468 private final Set<String> validTerms;
469
470 TermRule(String regex, String... validTerms) {
471 this.termPattern = compile(regex, Pattern.CASE_INSENSITIVE);
472 this.validTerms = ImmutableSet.copyOf(validTerms);
473 }
474
475 /**
476 * Checks whether the input satisfies the rule.
477 * Returns an error message if the check fails and empty string if the input is valid.
478 */
479 String check(String input) {
480 final Matcher m = termPattern.matcher(input);
481 if (m.find() && !validTerms.contains(m.group(0))) {
482 return String.format(Locale.ROOT, TERMINOLOGY_ERROR_MSG, m.group(0), validTerms);
483 }
484 return "";
485 }
486 }
487
488 private static void checkMessage(String subject, String body,
489 Consumer<String> consumer) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected