MapEntryRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!MapEntryRules\$).*
as compiler argument.
Table of contents
MapEntry
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapEntry")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!MapEntryRules\$MapEntry).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Map.Entry<String, Integer>> testMapEntry() {
- return ImmutableSet.of(
- Maps.immutableEntry("foo", 1), new AbstractMap.SimpleImmutableEntry<>("bar", 2));
+ return ImmutableSet.of(Map.entry("foo", 1), Map.entry("bar", 2));
}
MapEntryComparingByKey
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapEntryComparingByKey")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!MapEntryRules\$MapEntryComparingByKey).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Comparator<Map.Entry<Integer, String>>> testMapEntryComparingByKey() {
- return ImmutableSet.of(
- Comparator.comparing(Map.Entry::getKey),
- Map.Entry.comparingByKey(Comparator.naturalOrder()));
+ return ImmutableSet.of(comparingByKey(), comparingByKey());
}
MapEntryComparingByKeyWithCustomComparator
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapEntryComparingByKeyWithCustomComparator")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!MapEntryRules\$MapEntryComparingByKeyWithCustomComparator).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<Map.Entry<Integer, String>> testMapEntryComparingByKeyWithCustomComparator() {
- return Comparator.comparing(Map.Entry::getKey, Comparator.comparingInt(i -> i * 2));
+ return comparingByKey(Comparator.comparingInt(i -> i * 2));
}
MapEntryComparingByValue
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapEntryComparingByValue")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!MapEntryRules\$MapEntryComparingByValue).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Comparator<Map.Entry<Integer, String>>> testMapEntryComparingByValue() {
- return ImmutableSet.of(
- Comparator.comparing(Map.Entry::getValue),
- Map.Entry.comparingByValue(Comparator.naturalOrder()));
+ return ImmutableSet.of(comparingByValue(), comparingByValue());
}
MapEntryComparingByValueWithCustomComparator
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapEntryComparingByValueWithCustomComparator")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!MapEntryRules\$MapEntryComparingByValueWithCustomComparator).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Comparator<Map.Entry<Integer, String>> testMapEntryComparingByValueWithCustomComparator() {
- return Comparator.comparing(Map.Entry::getValue, Comparator.comparingInt(String::length));
+ return comparingByValue(Comparator.comparingInt(String::length));
}