PatternRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!PatternRules\$).* as compiler argument.

Table of contents
  1. PatternAsPredicate
  2. PatternCompileAsPredicate

PatternAsPredicate

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("PatternAsPredicate") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!PatternRules\$PatternAsPredicate).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 Predicate<?> testPatternAsPredicate() {
-  return Predicates.contains(Pattern.compile("foo"));
+  return Pattern.compile("foo").asPredicate();
 }

PatternCompileAsPredicate

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("PatternCompileAsPredicate") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!PatternRules\$PatternCompileAsPredicate).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 Predicate<?> testPatternCompileAsPredicate() {
-  return Predicates.containsPattern("foo");
+  return Pattern.compile("foo").asPredicate();
 }

Copyright © 2017-2024 Picnic Technologies BV