ImmutableMultisetRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableMultisetRules\$).*as compiler argument.
Table of contents
ImmutableMultisetBuilder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableMultisetBuilder")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableMultisetRules\$ImmutableMultisetBuilder).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableMultiset.Builder<String> testImmutableMultisetBuilder() {
- return new ImmutableMultiset.Builder<>();
+ return ImmutableMultiset.builder();
}ImmutableMultisetOf
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableMultisetOf")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableMultisetRules\$ImmutableMultisetOf).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<ImmutableMultiset<Integer>> testImmutableMultisetOf() {
- return ImmutableSet.of(
- ImmutableMultiset.<Integer>builder().build(),
- Stream.<Integer>empty().collect(toImmutableMultiset()));
+ return ImmutableSet.of(ImmutableMultiset.of(), ImmutableMultiset.of());
}ImmutableMultisetCopyOf
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ImmutableMultisetCopyOf")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableMultisetRules\$ImmutableMultisetCopyOf).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
@SuppressWarnings("unchecked" /* Safe generic array type creation. */)
ImmutableSet<ImmutableMultiset<Integer>> testImmutableMultisetCopyOf() {
return ImmutableSet.of(
- ImmutableMultiset.<Integer>builder().add(new Integer[] {1}).build(),
- Arrays.stream(new Integer[] {2}).collect(toImmutableMultiset()),
- ImmutableMultiset.<Integer>builder().addAll(ImmutableMultiset.of(3).iterator()).build(),
- Streams.stream(ImmutableList.of(4).iterator()).collect(toImmutableMultiset()),
- ImmutableMultiset.<Integer>builder().addAll(ImmutableMultiset.of(5)).build(),
- Streams.stream(ImmutableList.of(6)::iterator).collect(toImmutableMultiset()),
- ImmutableList.of(7).stream().collect(toImmutableMultiset()));
+ ImmutableMultiset.copyOf(new Integer[] {1}),
+ ImmutableMultiset.copyOf(new Integer[] {2}),
+ ImmutableMultiset.copyOf(ImmutableMultiset.of(3).iterator()),
+ ImmutableMultiset.copyOf(ImmutableList.of(4).iterator()),
+ ImmutableMultiset.copyOf(ImmutableMultiset.of(5)),
+ ImmutableMultiset.copyOf(ImmutableList.of(6)::iterator),
+ ImmutableMultiset.copyOf(ImmutableList.of(7)));
}StreamCollectToImmutableMultiset
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamCollectToImmutableMultiset")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!ImmutableMultisetRules\$StreamCollectToImmutableMultiset).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableMultiset<Integer> testStreamCollectToImmutableMultiset() {
- return ImmutableMultiset.copyOf(Stream.of(1).iterator());
+ return Stream.of(1).collect(toImmutableMultiset());
}