ImmutableListMultimapRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableListMultimapBuilder
  2. ImmutableListMultimapOf0
  3. ImmutableListMultimapOf2
  4. ImmutableListMultimapOfEntryGetKeyEntryGetValue
  5. ImmutableListMultimapCopyOf
  6. StreamCollectToImmutableListMultimap
  7. MultimapsIndex
  8. ImmutableListMultimapCopyOfMultimapsTransformValues
  9. ImmutableListMultimapCopyOfMultimapsTransformValuesWithFunction
  10. BuilderPut

ImmutableListMultimapBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableMultimap.Builder<String, Integer>> testImmutableListMultimapBuilder() {
   return ImmutableSet.of(
-      new ImmutableListMultimap.Builder<>(),
-      new ImmutableMultimap.Builder<>(),
-      ImmutableMultimap.builder());
+      ImmutableListMultimap.builder(),
+      ImmutableListMultimap.builder(),
+      ImmutableListMultimap.builder());
 }

ImmutableListMultimapOf0

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableMultimap<String, Integer>> testImmutableListMultimapOf0() {
-  return ImmutableSet.of(
-      ImmutableListMultimap.<String, Integer>builder().build(), ImmutableMultimap.of());
+  return ImmutableSet.of(ImmutableListMultimap.of(), ImmutableListMultimap.of());
 }

ImmutableListMultimapOf2

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableMultimap<String, Integer>> testImmutableListMultimapOf2() {
-  return ImmutableSet.of(
-      ImmutableListMultimap.<String, Integer>builder().put("foo", 1).build(),
-      ImmutableMultimap.of("bar", 2));
+  return ImmutableSet.of(ImmutableListMultimap.of("foo", 1), ImmutableListMultimap.of("bar", 2));
 }

ImmutableListMultimapOfEntryGetKeyEntryGetValue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableMultimap<String, Integer>>
     testImmutableListMultimapOfEntryGetKeyEntryGetValue() {
   return ImmutableSet.of(
-      ImmutableListMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
-      Stream.of(Map.entry("bar", 2))
-          .collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)));
+      ImmutableListMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
+      ImmutableListMultimap.of(Map.entry("bar", 2).getKey(), Map.entry("bar", 2).getValue()));
 }

ImmutableListMultimapCopyOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableMultimap<String, Integer>> testImmutableListMultimapCopyOf() {
   return ImmutableSet.of(
-      ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1).entries()),
-      ImmutableListMultimap.<String, Integer>builder()
-          .putAll(ImmutableListMultimap.of("bar", 2))
-          .build(),
-      ImmutableMultimap.copyOf(ImmutableListMultimap.of("baz", 3)),
-      ImmutableMultimap.copyOf(ImmutableListMultimap.of("qux", 4).entries()),
-      ImmutableListMultimap.<String, Integer>builder()
-          .putAll(Iterables.cycle(Map.entry("quux", 5)))
-          .build(),
-      Streams.stream(Iterables.cycle(Map.entry("corge", 6)))
-          .collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)),
-      ImmutableMultimap.copyOf(Iterables.cycle(Map.entry("grault", 7))),
-      ImmutableListMultimap.of("garply", 8).entries().stream()
-          .collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)));
+      ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1)),
+      ImmutableListMultimap.copyOf(ImmutableListMultimap.of("bar", 2)),
+      ImmutableListMultimap.copyOf(ImmutableListMultimap.of("baz", 3)),
+      ImmutableListMultimap.copyOf(ImmutableListMultimap.of("qux", 4)),
+      ImmutableListMultimap.copyOf(Iterables.cycle(Map.entry("quux", 5))),
+      ImmutableListMultimap.copyOf(Iterables.cycle(Map.entry("corge", 6))),
+      ImmutableListMultimap.copyOf(Iterables.cycle(Map.entry("grault", 7))),
+      ImmutableListMultimap.copyOf(ImmutableListMultimap.of("garply", 8).entries()));
 }

StreamCollectToImmutableListMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableListMultimap<Integer, String> testStreamCollectToImmutableListMultimap() {
-  return Stream.of(1, 2, 3)
-      .map(n -> Map.entry(n, n.toString()))
-      .collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue));
+  return Stream.of(1, 2, 3).collect(toImmutableListMultimap(n -> n, n -> n.toString()));
 }

MultimapsIndex

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableListMultimap<Integer, Integer>> testMultimapsIndex() {
   return ImmutableSet.of(
       Streams.stream(ImmutableList.of(1)::iterator)
           .collect(toImmutableListMultimap(Integer::valueOf, v -> 0)),
-      Streams.stream(ImmutableList.of(2)::iterator)
-          .collect(toImmutableListMultimap(Integer::valueOf, identity())),
+      Multimaps.index(ImmutableList.of(2)::iterator, Integer::valueOf),
       ImmutableList.of(3).stream().collect(toImmutableListMultimap(n -> n.intValue(), v -> 0)),
-      ImmutableList.of(4).stream()
-          .collect(toImmutableListMultimap(n -> n.intValue(), identity())),
+      Multimaps.index(ImmutableList.of(4), n -> n.intValue()),
       Streams.stream(ImmutableList.of(5).iterator())
           .collect(toImmutableListMultimap(n -> n * 2, v -> 0)),
-      Streams.stream(ImmutableList.of(6).iterator())
-          .collect(toImmutableListMultimap(n -> n * 2, identity())));
+      Multimaps.index(ImmutableList.of(6).iterator(), n -> n * 2));
 }

ImmutableListMultimapCopyOfMultimapsTransformValues

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableListMultimap<String, Integer> testImmutableListMultimapCopyOfMultimapsTransformValues() {
-  return ImmutableListMultimap.of("foo", 1L).entries().stream()
-      .collect(toImmutableListMultimap(Map.Entry::getKey, e -> Math.toIntExact(e.getValue())));
+  return ImmutableListMultimap.copyOf(
+      Multimaps.transformValues(ImmutableListMultimap.of("foo", 1L), v -> Math.toIntExact(v)));
 }

ImmutableListMultimapCopyOfMultimapsTransformValuesWithFunction

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableListMultimap<String, Integer>>
     testImmutableListMultimapCopyOfMultimapsTransformValuesWithFunction() {
   return ImmutableSet.of(
-      ImmutableSetMultimap.of("foo", 1L).asMap().entrySet().stream()
-          .collect(
-              flatteningToImmutableListMultimap(
-                  Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))),
-      Multimaps.asMap((Multimap<String, Long>) ImmutableSetMultimap.of("bar", 2L))
-          .entrySet()
-          .stream()
-          .collect(
-              flatteningToImmutableListMultimap(
-                  Map.Entry::getKey, e -> e.getValue().stream().map(n -> Math.toIntExact(n)))),
-      Multimaps.asMap(ImmutableListMultimap.of("baz", 3L)).entrySet().stream()
-          .collect(
-              flatteningToImmutableListMultimap(
-                  Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))),
-      Multimaps.asMap(ImmutableSetMultimap.of("qux", 4L)).entrySet().stream()
-          .collect(
-              flatteningToImmutableListMultimap(
-                  Map.Entry::getKey, e -> e.getValue().stream().map(n -> Math.toIntExact(n)))),
-      Multimaps.asMap(TreeMultimap.<String, Long>create()).entrySet().stream()
-          .collect(
-              flatteningToImmutableListMultimap(
-                  Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))));
+      ImmutableListMultimap.copyOf(
+          Multimaps.transformValues(ImmutableSetMultimap.of("foo", 1L), Math::toIntExact)),
+      ImmutableListMultimap.copyOf(
+          Multimaps.transformValues(
+              (Multimap<String, Long>) ImmutableSetMultimap.of("bar", 2L),
+              n -> Math.toIntExact(n))),
+      ImmutableListMultimap.copyOf(
+          Multimaps.transformValues(ImmutableListMultimap.of("baz", 3L), Math::toIntExact)),
+      ImmutableListMultimap.copyOf(
+          Multimaps.transformValues(ImmutableSetMultimap.of("qux", 4L), n -> Math.toIntExact(n))),
+      ImmutableListMultimap.copyOf(
+          Multimaps.transformValues(TreeMultimap.<String, Long>create(), Math::toIntExact)));
 }

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=^(?!ImmutableListMultimapRules\$BuilderPut).* as compiler argument.

Samples

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

 ImmutableSet<ImmutableListMultimap.Builder<String, Integer>> testBuilderPut() {
   return ImmutableSet.of(
-      ImmutableListMultimap.<String, Integer>builder().put(Map.entry("foo", 1)),
-      ImmutableListMultimap.<String, Integer>builder().putAll("bar", 2));
+      ImmutableListMultimap.<String, Integer>builder().put("foo", 1),
+      ImmutableListMultimap.<String, Integer>builder().put("bar", 2));
 }

Copyright © 2017-2026 Picnic Technologies BV