ImmutableSetMultimapRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableSetMultimapBuilder
  2. EmptyImmutableSetMultimap
  3. PairToImmutableSetMultimap
  4. EntryToImmutableSetMultimap
  5. IterableToImmutableSetMultimap
  6. StreamOfMapEntriesToImmutableSetMultimap
  7. TransformMultimapValuesToImmutableSetMultimap
  8. TransformMultimapValuesToImmutableSetMultimap2

ImmutableSetMultimapBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

EmptyImmutableSetMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSetMultimap<String, Integer> testEmptyImmutableSetMultimap() {
-  return ImmutableSetMultimap.<String, Integer>builder().build();
+  return ImmutableSetMultimap.of();
 }

PairToImmutableSetMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSetMultimap<String, Integer> testPairToImmutableSetMultimap() {
-  return ImmutableSetMultimap.<String, Integer>builder().put("foo", 1).build();
+  return ImmutableSetMultimap.of("foo", 1);
 }

EntryToImmutableSetMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableSetMultimap<String, Integer>> testEntryToImmutableSetMultimap() {
   return ImmutableSet.of(
-      ImmutableSetMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
-      Stream.of(Map.entry("foo", 1))
-          .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)));
+      ImmutableSetMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
+      ImmutableSetMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
 }

IterableToImmutableSetMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableSetMultimap<String, Integer>> testIterableToImmutableSetMultimap() {
   return ImmutableSet.of(
+      ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1)),
+      ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1)),
       ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1).entries()),
-      ImmutableSetMultimap.<String, Integer>builder()
-          .putAll(ImmutableSetMultimap.of("foo", 1))
-          .build(),
-      ImmutableSetMultimap.<String, Integer>builder()
-          .putAll(ImmutableSetMultimap.of("foo", 1).entries())
-          .build(),
-      ImmutableSetMultimap.of("foo", 1).entries().stream()
-          .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)),
-      Streams.stream(Iterables.cycle(Map.entry("foo", 1)))
-          .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)));
+      ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1).entries()),
+      ImmutableSetMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
 }

StreamOfMapEntriesToImmutableSetMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

TransformMultimapValuesToImmutableSetMultimap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

TransformMultimapValuesToImmutableSetMultimap2

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

Copyright © 2017-2024 Picnic Technologies BV