ComparatorRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$).*
as compiler argument.
Table of contents
- NaturalOrder
- ReverseOrder
- CustomComparator
- ComparingEnum
- ThenComparing
- ThenComparingReversed
- ThenComparingCustom
- ThenComparingCustomReversed
- ThenComparingDouble
- ThenComparingInt
- ThenComparingLong
- ThenComparingNaturalOrder
- CompareTo
- CollectionsSort
- CollectionsMin
- MinOfArray
- CollectionsMinWithComparator
- MinOfVarargs
- MinOfPairNaturalOrder
- MinOfPairCustomOrder
- CollectionsMax
- MaxOfArray
- CollectionsMaxWithComparator
- MaxOfVarargs
- MaxOfPairNaturalOrder
- MaxOfPairCustomOrder
- ComparatorsMin
- ComparatorsMax
- MinByNaturalOrder
- MaxByNaturalOrder
- IsLessThan
- IsLessThanOrEqualTo
NaturalOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("NaturalOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$NaturalOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Comparator<String>> testNaturalOrder() {
return ImmutableSet.of(
- String::compareTo,
- Comparator.comparing(identity()),
- Comparator.comparing(s -> s),
+ naturalOrder(),
+ naturalOrder(),
+ naturalOrder(),
Comparator.comparing(s -> 0),
- Collections.<String>reverseOrder(reverseOrder()),
- Comparator.<String>reverseOrder().reversed());
+ naturalOrder(),
+ naturalOrder());
}
ReverseOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ReverseOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ReverseOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Comparator<String>> testReverseOrder() {
return ImmutableSet.of(
- Collections.reverseOrder(),
- Collections.<String>reverseOrder(naturalOrder()),
- Comparator.<String>naturalOrder().reversed());
+ Comparator.reverseOrder(), Comparator.reverseOrder(), Comparator.reverseOrder());
}
CustomComparator
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CustomComparator")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CustomComparator).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Comparator<String>> testCustomComparator() {
return ImmutableSet.of(
- Comparator.comparing(identity(), Comparator.comparingInt(String::length)),
- Comparator.comparing(s -> s, Comparator.comparingInt(String::length)),
+ Comparator.comparingInt(String::length),
+ Comparator.comparingInt(String::length),
Comparator.comparing(s -> "foo", Comparator.comparingInt(String::length)));
}
ComparingEnum
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ComparingEnum")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ComparingEnum).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<String> testComparingEnum() {
- return Comparator.comparingInt(s -> RoundingMode.valueOf(s).ordinal());
+ return comparing(s -> RoundingMode.valueOf(s));
}
ThenComparing
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparing")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparing).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<String> testThenComparing() {
- return Comparator.<String>naturalOrder().thenComparing(Comparator.comparing(String::isEmpty));
+ return Comparator.<String>naturalOrder().thenComparing(String::isEmpty);
}
ThenComparingReversed
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingReversed")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingReversed).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<String> testThenComparingReversed() {
- return Comparator.<String>naturalOrder()
- .thenComparing(Comparator.comparing(String::isEmpty).reversed());
+ return Comparator.<String>naturalOrder().thenComparing(String::isEmpty, reverseOrder());
}
ThenComparingCustom
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingCustom")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingCustom).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<String> testThenComparingCustom() {
- return Comparator.<String>naturalOrder()
- .thenComparing(Comparator.comparing(String::isEmpty, reverseOrder()));
+ return Comparator.<String>naturalOrder().thenComparing(String::isEmpty, reverseOrder());
}
ThenComparingCustomReversed
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingCustomReversed")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingCustomReversed).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<String> testThenComparingCustomReversed() {
return Comparator.<String>naturalOrder()
- .thenComparing(
- Comparator.comparing(String::isEmpty, Comparator.<Boolean>reverseOrder()).reversed());
+ .thenComparing(String::isEmpty, Comparator.<Boolean>reverseOrder().reversed());
}
ThenComparingDouble
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingDouble")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingDouble).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<Integer> testThenComparingDouble() {
- return Comparator.<Integer>naturalOrder()
- .thenComparing(Comparator.comparingDouble(Integer::doubleValue));
+ return Comparator.<Integer>naturalOrder().thenComparingDouble(Integer::doubleValue);
}
ThenComparingInt
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingInt")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingInt).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<Integer> testThenComparingInt() {
- return Comparator.<Integer>naturalOrder()
- .thenComparing(Comparator.comparingInt(Integer::intValue));
+ return Comparator.<Integer>naturalOrder().thenComparingInt(Integer::intValue);
}
ThenComparingLong
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingLong")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingLong).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<Integer> testThenComparingLong() {
- return Comparator.<Integer>naturalOrder()
- .thenComparing(Comparator.comparingLong(Integer::longValue));
+ return Comparator.<Integer>naturalOrder().thenComparingLong(Integer::longValue);
}
ThenComparingNaturalOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ThenComparingNaturalOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ThenComparingNaturalOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Comparator<String>> testThenComparingNaturalOrder() {
return ImmutableSet.of(
- Comparator.<String>naturalOrder().thenComparing(identity()),
- Comparator.<String>naturalOrder().thenComparing(s -> s),
+ Comparator.<String>naturalOrder().thenComparing(naturalOrder()),
+ Comparator.<String>naturalOrder().thenComparing(naturalOrder()),
Comparator.<String>naturalOrder().thenComparing(s -> 0));
}
CompareTo
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CompareTo")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CompareTo).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Integer> testCompareTo() {
- return ImmutableSet.of(
- Comparator.<String>naturalOrder().compare("foo", "bar"),
- Comparator.<String>reverseOrder().compare("baz", "qux"));
+ return ImmutableSet.of("foo".compareTo("bar"), "qux".compareTo("baz"));
}
CollectionsSort
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CollectionsSort")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CollectionsSort).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCollectionsSort() {
- Collections.sort(ImmutableList.of("foo", "bar"), naturalOrder());
+ Collections.sort(ImmutableList.of("foo", "bar"));
}
CollectionsMin
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CollectionsMin")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CollectionsMin).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<String> testCollectionsMin() {
return ImmutableSet.of(
- Collections.min(ImmutableList.of("foo"), naturalOrder()),
- Collections.max(ImmutableList.of("bar"), reverseOrder()));
+ Collections.min(ImmutableList.of("foo")), Collections.min(ImmutableList.of("bar")));
}
MinOfArray
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MinOfArray")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MinOfArray).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testMinOfArray() {
- return Arrays.stream(new String[0]).min(naturalOrder()).orElseThrow();
+ return Collections.min(Arrays.asList(new String[0]), naturalOrder());
}
CollectionsMinWithComparator
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CollectionsMinWithComparator")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CollectionsMinWithComparator).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testCollectionsMinWithComparator() {
- return ImmutableSet.of("foo", "bar").stream().min(naturalOrder()).orElseThrow();
+ return Collections.min(ImmutableSet.of("foo", "bar"), naturalOrder());
}
MinOfVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MinOfVarargs")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MinOfVarargs).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
int testMinOfVarargs() {
- return Stream.of(1, 2).min(naturalOrder()).orElseThrow();
+ return Collections.min(Arrays.asList(1, 2), naturalOrder());
}
MinOfPairNaturalOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MinOfPairNaturalOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MinOfPairNaturalOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<String> testMinOfPairNaturalOrder() {
return ImmutableSet.of(
- "a".compareTo("b") <= 0 ? "a" : "b",
- "a".compareTo("b") > 0 ? "b" : "a",
- "a".compareTo("b") < 0 ? "a" : "b",
- "a".compareTo("b") >= 0 ? "b" : "a",
- Comparators.min("a", "b", naturalOrder()),
- Comparators.max("a", "b", reverseOrder()),
- Collections.min(Arrays.asList("a", "b")),
- Collections.min(ImmutableList.of("a", "b")),
- Collections.min(ImmutableSet.of("a", "b")));
+ Comparators.min("a", "b"),
+ Comparators.min("a", "b"),
+ Comparators.min("b", "a"),
+ Comparators.min("b", "a"),
+ Comparators.min("a", "b"),
+ Comparators.min("a", "b"),
+ Comparators.min("a", "b"),
+ Comparators.min("a", "b"),
+ Comparators.min("a", "b"));
}
MinOfPairCustomOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MinOfPairCustomOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MinOfPairCustomOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Object> testMinOfPairCustomOrder() {
return ImmutableSet.of(
- Comparator.comparingInt(String::length).compare("a", "b") <= 0 ? "a" : "b",
- Comparator.comparingInt(String::length).compare("a", "b") > 0 ? "b" : "a",
- Comparator.comparingInt(String::length).compare("a", "b") < 0 ? "a" : "b",
- Comparator.comparingInt(String::length).compare("a", "b") >= 0 ? "b" : "a",
- Collections.min(Arrays.asList("a", "b"), (a, b) -> -1),
- Collections.min(ImmutableList.of("a", "b"), (a, b) -> 0),
- Collections.min(ImmutableSet.of("a", "b"), (a, b) -> 1));
+ Comparators.min("a", "b", Comparator.comparingInt(String::length)),
+ Comparators.min("a", "b", Comparator.comparingInt(String::length)),
+ Comparators.min("b", "a", Comparator.comparingInt(String::length)),
+ Comparators.min("b", "a", Comparator.comparingInt(String::length)),
+ Comparators.min("a", "b", (a, b) -> -1),
+ Comparators.min("a", "b", (a, b) -> 0),
+ Comparators.min("a", "b", (a, b) -> 1));
}
CollectionsMax
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CollectionsMax")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CollectionsMax).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<String> testCollectionsMax() {
return ImmutableSet.of(
- Collections.max(ImmutableList.of("foo"), naturalOrder()),
- Collections.min(ImmutableList.of("bar"), reverseOrder()));
+ Collections.max(ImmutableList.of("foo")), Collections.max(ImmutableList.of("bar")));
}
MaxOfArray
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MaxOfArray")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MaxOfArray).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testMaxOfArray() {
- return Arrays.stream(new String[0]).max(naturalOrder()).orElseThrow();
+ return Collections.max(Arrays.asList(new String[0]), naturalOrder());
}
CollectionsMaxWithComparator
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CollectionsMaxWithComparator")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$CollectionsMaxWithComparator).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testCollectionsMaxWithComparator() {
- return ImmutableSet.of("foo", "bar").stream().max(naturalOrder()).orElseThrow();
+ return Collections.max(ImmutableSet.of("foo", "bar"), naturalOrder());
}
MaxOfVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MaxOfVarargs")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MaxOfVarargs).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
int testMaxOfVarargs() {
- return Stream.of(1, 2).max(naturalOrder()).orElseThrow();
+ return Collections.max(Arrays.asList(1, 2), naturalOrder());
}
MaxOfPairNaturalOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MaxOfPairNaturalOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MaxOfPairNaturalOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<String> testMaxOfPairNaturalOrder() {
return ImmutableSet.of(
- "a".compareTo("b") >= 0 ? "a" : "b",
- "a".compareTo("b") < 0 ? "b" : "a",
- "a".compareTo("b") > 0 ? "a" : "b",
- "a".compareTo("b") <= 0 ? "b" : "a",
- Comparators.max("a", "b", naturalOrder()),
- Comparators.min("a", "b", reverseOrder()),
- Collections.max(Arrays.asList("a", "b")),
- Collections.max(ImmutableList.of("a", "b")),
- Collections.max(ImmutableSet.of("a", "b")));
+ Comparators.max("a", "b"),
+ Comparators.max("a", "b"),
+ Comparators.max("b", "a"),
+ Comparators.max("b", "a"),
+ Comparators.max("a", "b"),
+ Comparators.max("a", "b"),
+ Comparators.max("a", "b"),
+ Comparators.max("a", "b"),
+ Comparators.max("a", "b"));
}
MaxOfPairCustomOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MaxOfPairCustomOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MaxOfPairCustomOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Object> testMaxOfPairCustomOrder() {
return ImmutableSet.of(
- Comparator.comparingInt(String::length).compare("a", "b") >= 0 ? "a" : "b",
- Comparator.comparingInt(String::length).compare("a", "b") < 0 ? "b" : "a",
- Comparator.comparingInt(String::length).compare("a", "b") > 0 ? "a" : "b",
- Comparator.comparingInt(String::length).compare("a", "b") <= 0 ? "b" : "a",
- Collections.max(Arrays.asList("a", "b"), (a, b) -> -1),
- Collections.max(ImmutableList.of("a", "b"), (a, b) -> 0),
- Collections.max(ImmutableSet.of("a", "b"), (a, b) -> 1));
+ Comparators.max("a", "b", Comparator.comparingInt(String::length)),
+ Comparators.max("a", "b", Comparator.comparingInt(String::length)),
+ Comparators.max("b", "a", Comparator.comparingInt(String::length)),
+ Comparators.max("b", "a", Comparator.comparingInt(String::length)),
+ Comparators.max("a", "b", (a, b) -> -1),
+ Comparators.max("a", "b", (a, b) -> 0),
+ Comparators.max("a", "b", (a, b) -> 1));
}
ComparatorsMin
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ComparatorsMin")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ComparatorsMin).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
BinaryOperator<String> testComparatorsMin() {
- return BinaryOperator.minBy(naturalOrder());
+ return Comparators::min;
}
ComparatorsMax
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ComparatorsMax")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$ComparatorsMax).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
BinaryOperator<String> testComparatorsMax() {
- return BinaryOperator.maxBy(naturalOrder());
+ return Comparators::max;
}
MinByNaturalOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MinByNaturalOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MinByNaturalOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Collector<Integer, ?, Optional<Integer>> testMinByNaturalOrder() {
- return maxBy(reverseOrder());
+ return minBy(naturalOrder());
}
MaxByNaturalOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MaxByNaturalOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$MaxByNaturalOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Collector<Integer, ?, Optional<Integer>> testMaxByNaturalOrder() {
- return minBy(reverseOrder());
+ return maxBy(naturalOrder());
}
IsLessThan
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IsLessThan")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$IsLessThan).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testIsLessThan() {
return ImmutableSet.of(
- RoundingMode.UP.ordinal() < RoundingMode.DOWN.ordinal(),
- RoundingMode.UP.ordinal() >= RoundingMode.DOWN.ordinal());
+ RoundingMode.UP.compareTo(RoundingMode.DOWN) < 0,
+ RoundingMode.UP.compareTo(RoundingMode.DOWN) >= 0);
}
IsLessThanOrEqualTo
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IsLessThanOrEqualTo")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ComparatorRules\$IsLessThanOrEqualTo).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testIsLessThanOrEqualTo() {
return ImmutableSet.of(
- RoundingMode.UP.ordinal() <= RoundingMode.DOWN.ordinal(),
- RoundingMode.UP.ordinal() > RoundingMode.DOWN.ordinal());
+ RoundingMode.UP.compareTo(RoundingMode.DOWN) <= 0,
+ RoundingMode.UP.compareTo(RoundingMode.DOWN) > 0);
}