IntStreamRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$).*as compiler argument.
Table of contents
- IntStreamRange
- IntStreamIdentity
- IntStreamConcat
- IntStreamFlatMapFilter
- StreamFlatMapToIntFilter
- IntStreamFlatMapMap
- StreamFlatMapToIntMap
- IntStreamFlatMapFlatMap
- StreamFlatMapToIntFlatMap
- IntStreamFilterSorted
- IntStreamFindAnyIsEmpty
- IntStreamFindAnyIsPresent
- IntStreamMin
- IntStreamNoneMatchWithIntPredicate
- IntStreamNoneMatch
- IntStreamAnyMatch
- IntStreamAllMatchWithIntPredicate
- IntStreamAllMatch
- IntStreamTakeWhile
IntStreamRange
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamRange")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamRange).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamRange() {
- return IntStream.rangeClosed(0, 42 - 1);
+ return IntStream.range(0, 42);
}IntStreamIdentity
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamIdentity")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamIdentity).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamIdentity() {
- return Streams.concat(IntStream.of(1));
+ return IntStream.of(1);
}IntStreamConcat
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamConcat")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamConcat).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamConcat() {
- return Streams.concat(IntStream.of(1), IntStream.of(2));
+ return IntStream.concat(IntStream.of(1), IntStream.of(2));
}IntStreamFlatMapFilter
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamFlatMapFilter")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamFlatMapFilter).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamFlatMapFilter() {
- return IntStream.of(1).flatMap(v -> IntStream.of(v * v).filter(n -> n > 1));
+ return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).filter(n -> n > 1);
}StreamFlatMapToIntFilter
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamFlatMapToIntFilter")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$StreamFlatMapToIntFilter).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testStreamFlatMapToIntFilter() {
- return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).filter(n -> n > 1));
+ return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).filter(n -> n > 1);
}IntStreamFlatMapMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamFlatMapMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamFlatMapMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamFlatMapMap() {
- return IntStream.of(1).flatMap(v -> IntStream.of(v * v).map(n -> n * 1));
+ return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).map(n -> n * 1);
}StreamFlatMapToIntMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamFlatMapToIntMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$StreamFlatMapToIntMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testStreamFlatMapToIntMap() {
- return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).map(n -> n * 1));
+ return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).map(n -> n * 1);
}IntStreamFlatMapFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamFlatMapFlatMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamFlatMapFlatMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamFlatMapFlatMap() {
- return IntStream.of(1).flatMap(v -> IntStream.of(v * v).flatMap(IntStream::of));
+ return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).flatMap(IntStream::of);
}StreamFlatMapToIntFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamFlatMapToIntFlatMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$StreamFlatMapToIntFlatMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testStreamFlatMapToIntFlatMap() {
- return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).flatMap(IntStream::of));
+ return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).flatMap(IntStream::of);
}IntStreamFilterSorted
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamFilterSorted")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamFilterSorted).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamFilterSorted() {
- return IntStream.of(1).sorted().filter(i -> i > 0);
+ return IntStream.of(1).filter(i -> i > 0).sorted();
}IntStreamFindAnyIsEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamFindAnyIsEmpty")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamFindAnyIsEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testIntStreamFindAnyIsEmpty() {
return ImmutableSet.of(
- IntStream.of(1).count() == 0,
- IntStream.of(2).count() <= 0,
- IntStream.of(3).count() < 1,
- IntStream.of(4).findFirst().isEmpty());
+ IntStream.of(1).findAny().isEmpty(),
+ IntStream.of(2).findAny().isEmpty(),
+ IntStream.of(3).findAny().isEmpty(),
+ IntStream.of(4).findAny().isEmpty());
}IntStreamFindAnyIsPresent
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamFindAnyIsPresent")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamFindAnyIsPresent).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testIntStreamFindAnyIsPresent() {
return ImmutableSet.of(
- IntStream.of(1).count() != 0,
- IntStream.of(2).count() > 0,
- IntStream.of(3).count() >= 1,
- IntStream.of(4).findFirst().isPresent());
+ IntStream.of(1).findAny().isPresent(),
+ IntStream.of(2).findAny().isPresent(),
+ IntStream.of(3).findAny().isPresent(),
+ IntStream.of(4).findAny().isPresent());
}IntStreamMin
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamMin")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamMin).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
OptionalInt testIntStreamMin() {
- return IntStream.of(1).sorted().findFirst();
+ return IntStream.of(1).min();
}IntStreamNoneMatchWithIntPredicate
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamNoneMatchWithIntPredicate")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamNoneMatchWithIntPredicate).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testIntStreamNoneMatchWithIntPredicate() {
IntPredicate pred = i -> i > 0;
return ImmutableSet.of(
- !IntStream.of(1).anyMatch(n -> n > 1),
- IntStream.of(2).allMatch(pred.negate()),
- IntStream.of(3).filter(pred).findAny().isEmpty());
+ IntStream.of(1).noneMatch(n -> n > 1),
+ IntStream.of(2).noneMatch(pred),
+ IntStream.of(3).noneMatch(pred));
}IntStreamNoneMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamNoneMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamNoneMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testIntStreamNoneMatch() {
- return IntStream.of(1).allMatch(n -> !(n > 1));
+ return IntStream.of(1).noneMatch(n -> n > 1);
}IntStreamAnyMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamAnyMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamAnyMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testIntStreamAnyMatch() {
return ImmutableSet.of(
- !IntStream.of(1).noneMatch(n -> n > 1),
- IntStream.of(2).filter(n -> n > 2).findAny().isPresent());
+ IntStream.of(1).anyMatch(n -> n > 1), IntStream.of(2).anyMatch(n -> n > 2));
}IntStreamAllMatchWithIntPredicate
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamAllMatchWithIntPredicate")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamAllMatchWithIntPredicate).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testIntStreamAllMatchWithIntPredicate() {
IntPredicate pred = i -> i > 0;
- return IntStream.of(1).noneMatch(pred.negate());
+ return IntStream.of(1).allMatch(pred);
}IntStreamAllMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamAllMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamAllMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testIntStreamAllMatch() {
- return IntStream.of(1).noneMatch(n -> !(n > 1));
+ return IntStream.of(1).allMatch(n -> n > 1);
}IntStreamTakeWhile
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("IntStreamTakeWhile")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!IntStreamRules\$IntStreamTakeWhile).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
IntStream testIntStreamTakeWhile() {
- return IntStream.of(1).takeWhile(i -> i > 0).filter(i -> i > 0);
+ return IntStream.of(1).takeWhile(i -> i > 0);
}