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. BuilderBuildOrThrow
  3. ImmutableTableOfCellGetRowKeyCellGetColumnKeyCellGetValue
  4. StreamCollectToImmutableTable
  5. ImmutableTableOf
  6. BuilderPut

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

BuilderBuildOrThrow

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

ImmutableTableOfCellGetRowKeyCellGetColumnKeyCellGetValue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableTable<String, Integer, String>>
     testImmutableTableOfCellGetRowKeyCellGetColumnKeyCellGetValue() {
   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()));
 }

StreamCollectToImmutableTable

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableTable<Integer, String, Integer> testStreamCollectToImmutableTable() {
-  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();
 }

BuilderPut

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableTable.Builder<String, String, Integer>> testBuilderPut() {
   return ImmutableSet.of(
-      ImmutableTable.<String, String, Integer>builder()
-          .put(Tables.immutableCell("foo", "bar", 1)),
-      ImmutableTable.<String, String, Integer>builder()
-          .putAll(ImmutableTable.of("baz", "qux", 2)));
+      ImmutableTable.<String, String, Integer>builder().put("foo", "bar", 1),
+      ImmutableTable.<String, String, Integer>builder().put("baz", "qux", 2));
 }

Copyright © 2017-2026 Picnic Technologies BV