ImmutableSortedSetRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. ImmutableSortedSetBuilder
  2. ImmutableSortedSetNaturalOrderBuilder
  3. ImmutableSortedSetReverseOrderBuilder
  4. EmptyImmutableSortedSet
  5. IterableToImmutableSortedSet
  6. StreamToImmutableSortedSet

ImmutableSortedSetBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

ImmutableSortedSetNaturalOrderBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

ImmutableSortedSetReverseOrderBuilder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

EmptyImmutableSortedSet

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableSortedSet<Integer>> testEmptyImmutableSortedSet() {
-  return ImmutableSet.of(
-      ImmutableSortedSet.<Integer>naturalOrder().build(),
-      Stream.<Integer>empty().collect(toImmutableSortedSet(naturalOrder())));
+  return ImmutableSet.of(ImmutableSortedSet.of(), ImmutableSortedSet.of());
 }

IterableToImmutableSortedSet

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<ImmutableSortedSet<Integer>> testIterableToImmutableSortedSet() {
   // XXX: The first subexpression is not rewritten (`naturalOrder()` isn't dropped). WHY!?
   return ImmutableSet.of(
       ImmutableSortedSet.copyOf(naturalOrder(), ImmutableList.of(1)),
-      ImmutableSortedSet.copyOf(naturalOrder(), ImmutableList.of(2).iterator()),
-      ImmutableList.of(3).stream().collect(toImmutableSortedSet(naturalOrder())),
-      Streams.stream(ImmutableList.of(4)::iterator).collect(toImmutableSortedSet(naturalOrder())),
-      Streams.stream(ImmutableList.of(5).iterator())
-          .collect(toImmutableSortedSet(naturalOrder())),
-      ImmutableSortedSet.<Integer>naturalOrder().addAll(ImmutableSet.of(6)).build(),
-      ImmutableSortedSet.<Integer>naturalOrder().addAll(ImmutableSet.of(7)::iterator).build(),
-      ImmutableSortedSet.<Integer>naturalOrder().addAll(ImmutableSet.of(8).iterator()).build(),
-      ImmutableSortedSet.<Integer>naturalOrder().add(new Integer[] {9}).build(),
-      Arrays.stream(new Integer[] {10}).collect(toImmutableSortedSet(naturalOrder())));
+      ImmutableSortedSet.copyOf(ImmutableList.of(2).iterator()),
+      ImmutableSortedSet.copyOf(ImmutableList.of(3)),
+      ImmutableSortedSet.copyOf(ImmutableList.of(4)::iterator),
+      ImmutableSortedSet.copyOf(ImmutableList.of(5).iterator()),
+      ImmutableSortedSet.copyOf(ImmutableSet.of(6)),
+      ImmutableSortedSet.copyOf(ImmutableSet.of(7)::iterator),
+      ImmutableSortedSet.copyOf(ImmutableSet.of(8).iterator()),
+      ImmutableSortedSet.copyOf(new Integer[] {9}),
+      ImmutableSortedSet.copyOf(new Integer[] {10}));
 }

StreamToImmutableSortedSet

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSortedSet<Integer> testStreamToImmutableSortedSet() {
-  return ImmutableSortedSet.copyOf(Stream.of(1).iterator());
+  return Stream.of(1).collect(toImmutableSortedSet(naturalOrder()));
 }

Copyright © 2017-2024 Picnic Technologies BV