ClassRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ClassIsInstanceWithClassAndObject
  2. RefasterIsInstance
  3. ClassIsInstance
  4. ClassIsInstanceWithClass
  5. ClassCast

ClassIsInstanceWithClassAndObject

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 boolean testClassIsInstanceWithClassAndObject() {
-  return CharSequence.class.isAssignableFrom("foo".getClass());
+  return CharSequence.class.isInstance("foo");
 }

RefasterIsInstance

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 boolean testRefasterIsInstance() {
-  return CharSequence.class.isInstance("foo");
+  return "foo" instanceof CharSequence;
 }

ClassIsInstance

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 Predicate<String> testClassIsInstance() {
-  return s -> s instanceof CharSequence;
+  return CharSequence.class::isInstance;
 }

ClassIsInstanceWithClass

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 Predicate<String> testClassIsInstanceWithClass() {
   Class<?> clazz = CharSequence.class;
-  return s -> clazz.isInstance(s);
+  return clazz::isInstance;
 }

ClassCast

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 Function<Number, Integer> testClassCast() {
-  return i -> Integer.class.cast(i);
+  return Integer.class::cast;
 }

Copyright © 2017-2026 Picnic Technologies BV