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

ImmutableSortedMapRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableSortedMapBuilder
  2. ImmutableSortedMapNaturalOrderBuilder
  3. ImmutableSortedMapReverseOrderBuilder
  4. EmptyImmutableSortedMap
  5. PairToImmutableSortedMap
  6. EntryToImmutableSortedMap
  7. IterableToImmutableSortedMap

ImmutableSortedMapBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapBuilder() {
-    return new ImmutableSortedMap.Builder<>(Comparator.comparingInt(String::length));
+    return ImmutableSortedMap.orderedBy(Comparator.comparingInt(String::length));
   }

ImmutableSortedMapNaturalOrderBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapNaturalOrderBuilder() {
-    return ImmutableSortedMap.orderedBy(Comparator.<String>naturalOrder());
+    return ImmutableSortedMap.naturalOrder();
   }

ImmutableSortedMapReverseOrderBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapReverseOrderBuilder() {
-    return ImmutableSortedMap.orderedBy(Comparator.<String>reverseOrder());
+    return ImmutableSortedMap.reverseOrder();
   }

EmptyImmutableSortedMap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSortedMap<String, Integer> testEmptyImmutableSortedMap() {
-    return ImmutableSortedMap.<String, Integer>naturalOrder().build();
+    return ImmutableSortedMap.of();
   }

PairToImmutableSortedMap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSortedMap<String, Integer> testPairToImmutableSortedMap() {
-    return ImmutableSortedMap.<String, Integer>naturalOrder().put("foo", 1).build();
+    return ImmutableSortedMap.of("foo", 1);
   }

EntryToImmutableSortedMap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableSortedMap<String, Integer>> testEntryToImmutableSortedMap() {
     return ImmutableSet.of(
-        ImmutableSortedMap.<String, Integer>naturalOrder().put(Map.entry("foo", 1)).build(),
-        Stream.of(Map.entry("foo", 1))
-            .collect(toImmutableSortedMap(naturalOrder(), Map.Entry::getKey, Map.Entry::getValue)));
+        ImmutableSortedMap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
+        ImmutableSortedMap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
   }

IterableToImmutableSortedMap

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableSortedMap<String, Integer>> testIterableToImmutableSortedMap() {
     return ImmutableSet.of(
-        ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1), naturalOrder()),
+        ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1)),
+        ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1)),
+        ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1)),
         ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1).entrySet()),
-        ImmutableSortedMap.<String, Integer>naturalOrder()
-            .putAll(ImmutableSortedMap.of("foo", 1))
-            .build(),
-        ImmutableSortedMap.<String, Integer>naturalOrder()
-            .putAll(ImmutableSortedMap.of("foo", 1).entrySet())
-            .build(),
-        ImmutableSortedMap.of("foo", 1).entrySet().stream()
-            .collect(toImmutableSortedMap(naturalOrder(), Map.Entry::getKey, Map.Entry::getValue)),
-        Streams.stream(Iterables.cycle(Map.entry("foo", 1)))
-            .collect(toImmutableSortedMap(naturalOrder(), Map.Entry::getKey, Map.Entry::getValue)));
+        ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1).entrySet()),
+        ImmutableSortedMap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
   }

Copyright © 2017-2023 Picnic Technologies BV