ImmutableMultisetRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableMultisetBuilder
  2. EmptyImmutableMultiset
  3. IterableToImmutableMultiset
  4. StreamToImmutableMultiset

ImmutableMultisetBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableMultiset.Builder<String> testImmutableMultisetBuilder() {
-    return new ImmutableMultiset.Builder<>();
+    return ImmutableMultiset.builder();
   }

EmptyImmutableMultiset

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableMultiset<ImmutableMultiset<Integer>> testEmptyImmutableMultiset() {
-    return ImmutableMultiset.of(
-        ImmutableMultiset.<Integer>builder().build(),
-        Stream.<Integer>empty().collect(toImmutableMultiset()));
+    return ImmutableMultiset.of(ImmutableMultiset.of(), ImmutableMultiset.of());
   }

IterableToImmutableMultiset

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableMultiset<ImmutableMultiset<Integer>> testIterableToImmutableMultiset() {
     return ImmutableMultiset.of(
-        ImmutableList.of(1).stream().collect(toImmutableMultiset()),
-        Streams.stream(ImmutableList.of(2)::iterator).collect(toImmutableMultiset()),
-        Streams.stream(ImmutableList.of(3).iterator()).collect(toImmutableMultiset()),
-        ImmutableMultiset.<Integer>builder().addAll(ImmutableMultiset.of(4)).build(),
-        ImmutableMultiset.<Integer>builder().addAll(ImmutableMultiset.of(5)::iterator).build(),
-        ImmutableMultiset.<Integer>builder().addAll(ImmutableMultiset.of(6).iterator()).build(),
-        ImmutableMultiset.<Integer>builder().add(new Integer[] {7}).build(),
-        Arrays.stream(new Integer[] {8}).collect(toImmutableMultiset()));
+        ImmutableMultiset.copyOf(ImmutableList.of(1)),
+        ImmutableMultiset.copyOf(ImmutableList.of(2)::iterator),
+        ImmutableMultiset.copyOf(ImmutableList.of(3).iterator()),
+        ImmutableMultiset.copyOf(ImmutableMultiset.of(4)),
+        ImmutableMultiset.copyOf(ImmutableMultiset.of(5)::iterator),
+        ImmutableMultiset.copyOf(ImmutableMultiset.of(6).iterator()),
+        ImmutableMultiset.copyOf(new Integer[] {7}),
+        ImmutableMultiset.copyOf(new Integer[] {8}));
   }

StreamToImmutableMultiset

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableMultiset<Integer> testStreamToImmutableMultiset() {
-    return ImmutableMultiset.copyOf(Stream.of(1).iterator());
+    return Stream.of(1).collect(toImmutableMultiset());
   }

Copyright © 2017-2024 Picnic Technologies BV