ClassRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!ClassRules\$).*as compiler argument.
Table of contents
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.
 boolean testClassIsInstance() {
-  return CharSequence.class.isAssignableFrom("foo".getClass());
+  return CharSequence.class.isInstance("foo");
 }Instanceof
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("Instanceof")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ClassRules\$Instanceof).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
 ImmutableSet<Boolean> testInstanceof() {
   Class<?> clazz = CharSequence.class;
-  return ImmutableSet.of(CharSequence.class.isInstance("foo"), clazz.isInstance("bar"));
+  return ImmutableSet.of("foo" instanceof CharSequence, clazz.isInstance("bar"));
 }ClassLiteralIsInstancePredicate
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ClassLiteralIsInstancePredicate")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ClassRules\$ClassLiteralIsInstancePredicate).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
 Predicate<String> testClassLiteralIsInstancePredicate() {
-  return s -> s instanceof CharSequence;
+  return CharSequence.class::isInstance;
 }ClassReferenceIsInstancePredicate
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ClassReferenceIsInstancePredicate")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ClassRules\$ClassReferenceIsInstancePredicate).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
 Predicate<String> testClassReferenceIsInstancePredicate() {
   Class<?> clazz = CharSequence.class;
-  return s -> clazz.isInstance(s);
+  return clazz::isInstance;
 }ClassReferenceCast
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ClassReferenceCast")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ClassRules\$ClassReferenceCast).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
 Function<Number, Integer> testClassReferenceCast() {
-  return i -> Integer.class.cast(i);
+  return Integer.class::cast;
 }