ImmutableSetMultimapRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$).*as compiler argument.
Table of contents
- ImmutableSetMultimapBuilder
- ImmutableSetMultimapOf0
- ImmutableSetMultimapOf2
- ImmutableSetMultimapOfEntryGetKeyEntryGetValue
- ImmutableSetMultimapCopyOf
- StreamCollectToImmutableSetMultimap
- ImmutableSetMultimapCopyOfMultimapsTransformValues
- ImmutableSetMultimapCopyOfMultimapsTransformValuesWithFunction
- BuilderPut
ImmutableSetMultimapBuilder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapBuilder")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapBuilder).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSetMultimap.Builder<String, Integer> testImmutableSetMultimapBuilder() {
- return new ImmutableSetMultimap.Builder<>();
+ return ImmutableSetMultimap.builder();
}ImmutableSetMultimapOf0
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapOf0")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapOf0).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapOf0() {
- return ImmutableSetMultimap.<String, Integer>builder().build();
+ return ImmutableSetMultimap.of();
}ImmutableSetMultimapOf2
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapOf2")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapOf2).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapOf2() {
- return ImmutableSetMultimap.<String, Integer>builder().put("foo", 1).build();
+ return ImmutableSetMultimap.of("foo", 1);
}ImmutableSetMultimapOfEntryGetKeyEntryGetValue
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapOfEntryGetKeyEntryGetValue")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapOfEntryGetKeyEntryGetValue).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<ImmutableSetMultimap<String, Integer>>
testImmutableSetMultimapOfEntryGetKeyEntryGetValue() {
return ImmutableSet.of(
- ImmutableSetMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
- Stream.of(Map.entry("bar", 2))
- .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)));
+ ImmutableSetMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
+ ImmutableSetMultimap.of(Map.entry("bar", 2).getKey(), Map.entry("bar", 2).getValue()));
}ImmutableSetMultimapCopyOf
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapCopyOf")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapCopyOf).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<ImmutableSetMultimap<String, Integer>> testImmutableSetMultimapCopyOf() {
return ImmutableSet.of(
- ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1).entries()),
- ImmutableSetMultimap.<String, Integer>builder()
- .putAll(ImmutableSetMultimap.of("bar", 2))
- .build(),
- ImmutableSetMultimap.<String, Integer>builder()
- .putAll(ImmutableSetMultimap.of("baz", 3).entries())
- .build(),
- Streams.stream(Iterables.cycle(Map.entry("quux", 5)))
- .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)),
- ImmutableSetMultimap.of("qux", 4).entries().stream()
- .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)));
+ ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1)),
+ ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("bar", 2)),
+ ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("baz", 3).entries()),
+ ImmutableSetMultimap.copyOf(Iterables.cycle(Map.entry("quux", 5))),
+ ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("qux", 4).entries()));
}StreamCollectToImmutableSetMultimap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamCollectToImmutableSetMultimap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$StreamCollectToImmutableSetMultimap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSetMultimap<Integer, String> testStreamCollectToImmutableSetMultimap() {
- return Stream.of(1, 2, 3)
- .map(n -> Map.entry(n, n.toString()))
- .collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue));
+ return Stream.of(1, 2, 3).collect(toImmutableSetMultimap(n -> n, n -> n.toString()));
}ImmutableSetMultimapCopyOfMultimapsTransformValues
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapCopyOfMultimapsTransformValues")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapCopyOfMultimapsTransformValues).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapCopyOfMultimapsTransformValues() {
- return ImmutableSetMultimap.of("foo", 1L).entries().stream()
- .collect(toImmutableSetMultimap(Map.Entry::getKey, e -> Math.toIntExact(e.getValue())));
+ return ImmutableSetMultimap.copyOf(
+ Multimaps.transformValues(ImmutableSetMultimap.of("foo", 1L), e -> Math.toIntExact(e)));
}ImmutableSetMultimapCopyOfMultimapsTransformValuesWithFunction
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableSetMultimapCopyOfMultimapsTransformValuesWithFunction")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$ImmutableSetMultimapCopyOfMultimapsTransformValuesWithFunction).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<ImmutableSetMultimap<String, Integer>>
testImmutableSetMultimapCopyOfMultimapsTransformValuesWithFunction() {
return ImmutableSet.of(
- ImmutableSetMultimap.of("foo", 1L).asMap().entrySet().stream()
- .collect(
- flatteningToImmutableSetMultimap(
- Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))),
- Multimaps.asMap((Multimap<String, Long>) ImmutableSetMultimap.of("bar", 2L))
- .entrySet()
- .stream()
- .collect(
- flatteningToImmutableSetMultimap(
- Map.Entry::getKey, e -> e.getValue().stream().map(n -> Math.toIntExact(n)))),
- Multimaps.asMap(ImmutableListMultimap.of("baz", 3L)).entrySet().stream()
- .collect(
- flatteningToImmutableSetMultimap(
- Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))),
- Multimaps.asMap(ImmutableSetMultimap.of("qux", 4L)).entrySet().stream()
- .collect(
- flatteningToImmutableSetMultimap(
- Map.Entry::getKey, e -> e.getValue().stream().map(n -> Math.toIntExact(n)))),
- Multimaps.asMap(TreeMultimap.<String, Long>create()).entrySet().stream()
- .collect(
- flatteningToImmutableSetMultimap(
- Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))));
+ ImmutableSetMultimap.copyOf(
+ Multimaps.transformValues(ImmutableSetMultimap.of("foo", 1L), Math::toIntExact)),
+ ImmutableSetMultimap.copyOf(
+ Multimaps.transformValues(
+ (Multimap<String, Long>) ImmutableSetMultimap.of("bar", 2L),
+ n -> Math.toIntExact(n))),
+ ImmutableSetMultimap.copyOf(
+ Multimaps.transformValues(ImmutableListMultimap.of("baz", 3L), Math::toIntExact)),
+ ImmutableSetMultimap.copyOf(
+ Multimaps.transformValues(ImmutableSetMultimap.of("qux", 4L), n -> Math.toIntExact(n))),
+ ImmutableSetMultimap.copyOf(
+ Multimaps.transformValues(TreeMultimap.<String, Long>create(), Math::toIntExact)));
}BuilderPut
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("BuilderPut")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableSetMultimapRules\$BuilderPut).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<ImmutableSetMultimap.Builder<String, Integer>> testBuilderPut() {
return ImmutableSet.of(
- ImmutableSetMultimap.<String, Integer>builder().put(Map.entry("foo", 1)),
- ImmutableSetMultimap.<String, Integer>builder().putAll("bar", 2));
+ ImmutableSetMultimap.<String, Integer>builder().put("foo", 1),
+ ImmutableSetMultimap.<String, Integer>builder().put("bar", 2));
}