BigDecimalRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. BigDecimalZero
  2. BigDecimalOne
  3. BigDecimalTen
  4. BigDecimalValueOf
  5. BigDecimalSignumIsZero
  6. BigDecimalSignumIsPositive
  7. BigDecimalSignumIsNegative

BigDecimalZero

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<BigDecimal> testBigDecimalZero() {
-  return ImmutableSet.of(BigDecimal.valueOf(0), BigDecimal.valueOf(0L), new BigDecimal("0"));
+  return ImmutableSet.of(BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
 }

BigDecimalOne

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<BigDecimal> testBigDecimalOne() {
-  return ImmutableSet.of(BigDecimal.valueOf(1), BigDecimal.valueOf(1L), new BigDecimal("1"));
+  return ImmutableSet.of(BigDecimal.ONE, BigDecimal.ONE, BigDecimal.ONE);
 }

BigDecimalTen

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<BigDecimal> testBigDecimalTen() {
-  return ImmutableSet.of(BigDecimal.valueOf(10), BigDecimal.valueOf(10L), new BigDecimal("10"));
+  return ImmutableSet.of(BigDecimal.TEN, BigDecimal.TEN, BigDecimal.TEN);
 }

BigDecimalValueOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<BigDecimal> testBigDecimalValueOf() {
-  return ImmutableSet.of(new BigDecimal(2), new BigDecimal(2L), new BigDecimal(2.0));
+  return ImmutableSet.of(BigDecimal.valueOf(2), BigDecimal.valueOf(2L), BigDecimal.valueOf(2.0));
 }

BigDecimalSignumIsZero

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testBigDecimalSignumIsZero() {
   return ImmutableSet.of(
-      BigDecimal.valueOf(1).compareTo(BigDecimal.ZERO) == 0,
-      BigDecimal.ZERO.compareTo(BigDecimal.valueOf(2)) == 0,
-      BigDecimal.valueOf(3).compareTo(BigDecimal.ZERO) != 0,
-      BigDecimal.ZERO.compareTo(BigDecimal.valueOf(4)) != 0);
+      BigDecimal.valueOf(1).signum() == 0,
+      BigDecimal.valueOf(2).signum() == 0,
+      BigDecimal.valueOf(3).signum() != 0,
+      BigDecimal.valueOf(4).signum() != 0);
 }

BigDecimalSignumIsPositive

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testBigDecimalSignumIsPositive() {
   return ImmutableSet.of(
-      BigDecimal.valueOf(1).compareTo(BigDecimal.ZERO) > 0,
-      BigDecimal.ZERO.compareTo(BigDecimal.valueOf(2)) < 0,
-      BigDecimal.valueOf(3).signum() > 0,
-      BigDecimal.valueOf(4).signum() >= 1,
-      BigDecimal.valueOf(5).compareTo(BigDecimal.ZERO) <= 0,
-      BigDecimal.ZERO.compareTo(BigDecimal.valueOf(6)) >= 0,
-      BigDecimal.valueOf(7).signum() <= 0,
-      BigDecimal.valueOf(8).signum() < 1);
+      BigDecimal.valueOf(1).signum() == 1,
+      BigDecimal.valueOf(2).signum() == 1,
+      BigDecimal.valueOf(3).signum() == 1,
+      BigDecimal.valueOf(4).signum() == 1,
+      BigDecimal.valueOf(5).signum() != 1,
+      BigDecimal.valueOf(6).signum() != 1,
+      BigDecimal.valueOf(7).signum() != 1,
+      BigDecimal.valueOf(8).signum() != 1);
 }

BigDecimalSignumIsNegative

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Boolean> testBigDecimalSignumIsNegative() {
   return ImmutableSet.of(
-      BigDecimal.valueOf(1).compareTo(BigDecimal.ZERO) < 0,
-      BigDecimal.ZERO.compareTo(BigDecimal.valueOf(2)) > 0,
-      BigDecimal.valueOf(3).signum() < 0,
-      BigDecimal.valueOf(4).signum() <= -1,
-      BigDecimal.valueOf(5).compareTo(BigDecimal.ZERO) >= 0,
-      BigDecimal.ZERO.compareTo(BigDecimal.valueOf(6)) <= 0,
-      BigDecimal.valueOf(7).signum() >= 0,
-      BigDecimal.valueOf(8).signum() > -1);
+      BigDecimal.valueOf(1).signum() == -1,
+      BigDecimal.valueOf(2).signum() == -1,
+      BigDecimal.valueOf(3).signum() == -1,
+      BigDecimal.valueOf(4).signum() == -1,
+      BigDecimal.valueOf(5).signum() != -1,
+      BigDecimal.valueOf(6).signum() != -1,
+      BigDecimal.valueOf(7).signum() != -1,
+      BigDecimal.valueOf(8).signum() != -1);
 }

Copyright © 2017-2024 Picnic Technologies BV