ImmutableTableRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableTableBuilder
  2. ImmutableTableBuilderBuildOrThrow
  3. CellToImmutableTable
  4. StreamOfCellsToImmutableTable
  5. ImmutableTableOf

ImmutableTableBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableTable.Builder<String, Integer, String> testImmutableTableBuilder() {
-  return new ImmutableTable.Builder<>();
+  return ImmutableTable.builder();
 }

ImmutableTableBuilderBuildOrThrow

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableTable<Object, Object, Object> testImmutableTableBuilderBuildOrThrow() {
-  return ImmutableTable.builder().build();
+  return ImmutableTable.builder().buildOrThrow();
 }

CellToImmutableTable

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableTable<String, Integer, String>> testCellToImmutableTable() {
   return ImmutableSet.of(
-      ImmutableTable.<String, Integer, String>builder()
-          .put(Tables.immutableCell("foo", 1, "bar"))
-          .buildOrThrow(),
-      Stream.of(Tables.immutableCell("baz", 2, "qux"))
-          .collect(
-              toImmutableTable(
-                  Table.Cell::getRowKey, Table.Cell::getColumnKey, Table.Cell::getValue)));
+      ImmutableTable.of(
+          Tables.immutableCell("foo", 1, "bar").getRowKey(),
+          Tables.immutableCell("foo", 1, "bar").getColumnKey(),
+          Tables.immutableCell("foo", 1, "bar").getValue()),
+      ImmutableTable.of(
+          Tables.immutableCell("baz", 2, "qux").getRowKey(),
+          Tables.immutableCell("baz", 2, "qux").getColumnKey(),
+          Tables.immutableCell("baz", 2, "qux").getValue()));
 }

StreamOfCellsToImmutableTable

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableTable<Integer, String, Integer> testStreamOfCellsToImmutableTable() {
-  return Stream.of(1, 2, 3)
-      .map(n -> Tables.immutableCell(n, n.toString(), n * 2))
-      .collect(
-          toImmutableTable(
-              Table.Cell::getRowKey, Table.Cell::getColumnKey, Table.Cell::getValue));
+  return Stream.of(1, 2, 3).collect(toImmutableTable(n -> n, n -> n.toString(), n -> n * 2));
 }

ImmutableTableOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableTable<String, String, String> testImmutableTableOf() {
-  return ImmutableTable.<String, String, String>builder().buildOrThrow();
+  return ImmutableTable.of();
 }

Copyright © 2017-2024 Picnic Technologies BV