Skip to main content Link Search Menu Expand Document (external link)

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

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));
   }

Copyright © 2017-2023 Picnic Technologies BV