Skip to main content Link Search Menu Expand Document (external link)

ImmutableSortedMultisetRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableSortedMultisetBuilder
  2. ImmutableSortedMultisetNaturalOrderBuilder
  3. ImmutableSortedMultisetReverseOrderBuilder
  4. EmptyImmutableSortedMultiset
  5. IterableToImmutableSortedMultiset
  6. StreamToImmutableSortedMultiset

ImmutableSortedMultisetBuilder

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(ImmutableSortedMultisetRules\.ImmutableSortedMultisetBuilder)) as compiler argument.

Samples

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

 ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetBuilder() {
-    return new ImmutableSortedMultiset.Builder<>(Comparator.comparingInt(String::length));
+    return ImmutableSortedMultiset.orderedBy(Comparator.comparingInt(String::length));
   }

ImmutableSortedMultisetNaturalOrderBuilder

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(ImmutableSortedMultisetRules\.ImmutableSortedMultisetNaturalOrderBuilder)) as compiler argument.

Samples

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

 ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetNaturalOrderBuilder() {
-    return ImmutableSortedMultiset.orderedBy(Comparator.<String>naturalOrder());
+    return ImmutableSortedMultiset.naturalOrder();
   }

ImmutableSortedMultisetReverseOrderBuilder

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(ImmutableSortedMultisetRules\.ImmutableSortedMultisetReverseOrderBuilder)) as compiler argument.

Samples

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

 ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetReverseOrderBuilder() {
-    return ImmutableSortedMultiset.orderedBy(Comparator.<String>reverseOrder());
+    return ImmutableSortedMultiset.reverseOrder();
   }

EmptyImmutableSortedMultiset

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(ImmutableSortedMultisetRules\.EmptyImmutableSortedMultiset)) as compiler argument.

Samples

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

 ImmutableMultiset<ImmutableSortedMultiset<Integer>> testEmptyImmutableSortedMultiset() {
-    return ImmutableMultiset.of(
-        ImmutableSortedMultiset.<Integer>naturalOrder().build(),
-        Stream.<Integer>empty().collect(toImmutableSortedMultiset(naturalOrder())));
+    return ImmutableMultiset.of(ImmutableSortedMultiset.of(), ImmutableSortedMultiset.of());
   }

IterableToImmutableSortedMultiset

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(ImmutableSortedMultisetRules\.IterableToImmutableSortedMultiset)) as compiler argument.

Samples

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

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

StreamToImmutableSortedMultiset

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(ImmutableSortedMultisetRules\.StreamToImmutableSortedMultiset)) as compiler argument.

Samples

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

 ImmutableSortedMultiset<Integer> testStreamToImmutableSortedMultiset() {
-    return ImmutableSortedMultiset.copyOf(Stream.of(1).iterator());
+    return Stream.of(1).collect(toImmutableSortedMultiset(naturalOrder()));
   }

Copyright © 2017-2023 Picnic Technologies BV