PrimitiveRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. LessThan
  2. LessThanOrEqualTo
  3. GreaterThan
  4. GreaterThanOrEqualTo
  5. LongToIntExact
  6. BooleanHashCode
  7. ByteHashCode
  8. CharacterHashCode
  9. ShortHashCode
  10. IntegerHashCode
  11. LongHashCode
  12. FloatHashCode
  13. DoubleHashCode
  14. BooleanCompare
  15. CharacterCompare
  16. ShortCompare
  17. IntegerCompare
  18. LongCompare
  19. FloatCompare
  20. DoubleCompare
  21. CharacterBytes
  22. ShortBytes
  23. IntegerBytes
  24. LongBytes
  25. FloatBytes
  26. DoubleBytes
  27. FloatIsFinite
  28. DoubleIsFinite
  29. IntegerSignumIsPositive
  30. IntegerSignumIsNegative
  31. LongSignumIsPositive
  32. LongSignumIsNegative

LessThan

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testLessThan() {
     return ImmutableSet.of(
-        !((byte) 3 >= (byte) 4),
-        !((char) 3 >= (char) 4),
-        !((short) 3 >= (short) 4),
-        !(3 >= 4),
-        !(3L >= 4L),
-        !(3F >= 4F),
-        !(3.0 >= 4.0));
+        (byte) 3 < (byte) 4,
+        (char) 3 < (char) 4,
+        (short) 3 < (short) 4,
+        3 < 4,
+        3L < 4L,
+        3F < 4F,
+        3.0 < 4.0);
   }

LessThanOrEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testLessThanOrEqualTo() {
     return ImmutableSet.of(
-        !((byte) 3 > (byte) 4),
-        !((char) 3 > (char) 4),
-        !((short) 3 > (short) 4),
-        !(3 > 4),
-        !(3L > 4L),
-        !(3F > 4F),
-        !(3.0 > 4.0));
+        (byte) 3 <= (byte) 4,
+        (char) 3 <= (char) 4,
+        (short) 3 <= (short) 4,
+        3 <= 4,
+        3L <= 4L,
+        3F <= 4F,
+        3.0 <= 4.0);
   }

GreaterThan

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testGreaterThan() {
     return ImmutableSet.of(
-        !((byte) 3 <= (byte) 4),
-        !((char) 3 <= (char) 4),
-        !((short) 3 <= (short) 4),
-        !(3 <= 4),
-        !(3L <= 4L),
-        !(3F <= 4F),
-        !(3.0 <= 4.0));
+        (byte) 3 > (byte) 4,
+        (char) 3 > (char) 4,
+        (short) 3 > (short) 4,
+        3 > 4,
+        3L > 4L,
+        3F > 4F,
+        3.0 > 4.0);
   }

GreaterThanOrEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testGreaterThanOrEqualTo() {
     return ImmutableSet.of(
-        !((byte) 3 < (byte) 4),
-        !((char) 3 < (char) 4),
-        !((short) 3 < (short) 4),
-        !(3 < 4),
-        !(3L < 4L),
-        !(3F < 4F),
-        !(3.0 < 4.0));
+        (byte) 3 >= (byte) 4,
+        (char) 3 >= (char) 4,
+        (short) 3 >= (short) 4,
+        3 >= 4,
+        3L >= 4L,
+        3F >= 4F,
+        3.0 >= 4.0);
   }

LongToIntExact

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testLongToIntExact() {
-    return Ints.checkedCast(Long.MAX_VALUE);
+    return Math.toIntExact(Long.MAX_VALUE);
   }

BooleanHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testBooleanHashCode() {
-    return Booleans.hashCode(true);
+    return Boolean.hashCode(true);
   }

ByteHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testByteHashCode() {
-    return Bytes.hashCode((byte) 1);
+    return Byte.hashCode((byte) 1);
   }

CharacterHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testCharacterHashCode() {
-    return Chars.hashCode('a');
+    return Character.hashCode('a');
   }

ShortHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testShortHashCode() {
-    return Shorts.hashCode((short) 1);
+    return Short.hashCode((short) 1);
   }

IntegerHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testIntegerHashCode() {
-    return Ints.hashCode(1);
+    return Integer.hashCode(1);
   }

LongHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testLongHashCode() {
-    return Longs.hashCode(1);
+    return Long.hashCode(1);
   }

FloatHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testFloatHashCode() {
-    return Floats.hashCode(1);
+    return Float.hashCode(1);
   }

DoubleHashCode

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testDoubleHashCode() {
-    return Doubles.hashCode(1);
+    return Double.hashCode(1);
   }

BooleanCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testBooleanCompare() {
-    return Booleans.compare(false, true);
+    return Boolean.compare(false, true);
   }

CharacterCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testCharacterCompare() {
-    return Chars.compare('a', 'b');
+    return Character.compare('a', 'b');
   }

ShortCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testShortCompare() {
-    return Shorts.compare((short) 1, (short) 2);
+    return Short.compare((short) 1, (short) 2);
   }

IntegerCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testIntegerCompare() {
-    return Ints.compare(1, 2);
+    return Integer.compare(1, 2);
   }

LongCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testLongCompare() {
-    return Longs.compare(1, 2);
+    return Long.compare(1, 2);
   }

FloatCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testFloatCompare() {
-    return Floats.compare(1, 2);
+    return Float.compare(1, 2);
   }

DoubleCompare

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testDoubleCompare() {
-    return Doubles.compare(1, 2);
+    return Double.compare(1, 2);
   }

CharacterBytes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testCharacterBytes() {
-    return Chars.BYTES;
+    return Character.BYTES;
   }

ShortBytes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testShortBytes() {
-    return Shorts.BYTES;
+    return Short.BYTES;
   }

IntegerBytes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testIntegerBytes() {
-    return Ints.BYTES;
+    return Integer.BYTES;
   }

LongBytes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testLongBytes() {
-    return Longs.BYTES;
+    return Long.BYTES;
   }

FloatBytes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testFloatBytes() {
-    return Floats.BYTES;
+    return Float.BYTES;
   }

DoubleBytes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 int testDoubleBytes() {
-    return Doubles.BYTES;
+    return Double.BYTES;
   }

FloatIsFinite

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 boolean testFloatIsFinite() {
-    return Floats.isFinite(1);
+    return Float.isFinite(1);
   }

DoubleIsFinite

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 boolean testDoubleIsFinite() {
-    return Doubles.isFinite(1);
+    return Double.isFinite(1);
   }

IntegerSignumIsPositive

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testIntegerSignumIsPositive() {
     return ImmutableSet.of(
-        Integer.signum(1) > 0,
-        Integer.signum(2) >= 1,
-        Integer.signum(3) <= 0,
-        Integer.signum(4) < 1);
+        Integer.signum(1) == 1,
+        Integer.signum(2) == 1,
+        Integer.signum(3) != 1,
+        Integer.signum(4) != 1);
   }

IntegerSignumIsNegative

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testIntegerSignumIsNegative() {
     return ImmutableSet.of(
-        Integer.signum(1) < 0,
-        Integer.signum(2) <= -1,
-        Integer.signum(3) >= 0,
-        Integer.signum(4) > -1);
+        Integer.signum(1) == -1,
+        Integer.signum(2) == -1,
+        Integer.signum(3) != -1,
+        Integer.signum(4) != -1);
   }

LongSignumIsPositive

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testLongSignumIsPositive() {
     return ImmutableSet.of(
-        Long.signum(1L) > 0, Long.signum(2L) >= 1, Long.signum(3L) <= 0, Long.signum(4L) < 1);
+        Long.signum(1L) == 1, Long.signum(2L) == 1, Long.signum(3L) != 1, Long.signum(4L) != 1);
   }

LongSignumIsNegative

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testLongSignumIsNegative() {
     return ImmutableSet.of(
-        Long.signum(1L) < 0, Long.signum(2L) <= -1, Long.signum(3L) >= 0, Long.signum(4L) > -1);
+        Long.signum(1L) == -1, Long.signum(2L) == -1, Long.signum(3L) != -1, Long.signum(4L) != -1);
   }

Copyright © 2017-2024 Picnic Technologies BV