LongStreamRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$).*as compiler argument.
Table of contents
- LongStreamRange
- LongStreamIdentity
- LongStreamConcat
- LongStreamFlatMapFilter
- StreamFlatMapToLongFilter
- LongStreamFlatMapMap
- StreamFlatMapToLongMap
- LongStreamFlatMapFlatMap
- StreamFlatMapToLongFlatMap
- LongStreamFilterSorted
- LongStreamFindAnyIsEmpty
- LongStreamFindAnyIsPresent
- LongStreamMin
- LongStreamNoneMatchWithLongPredicate
- LongStreamNoneMatch
- LongStreamAnyMatch
- LongStreamAllMatchWithLongPredicate
- LongStreamAllMatch
- LongStreamTakeWhile
LongStreamRange
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamRange")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamRange).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamRange() {
- return LongStream.rangeClosed(0, 42 - 1);
+ return LongStream.range(0, 42);
}LongStreamIdentity
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamIdentity")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamIdentity).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamIdentity() {
- return Streams.concat(LongStream.of(1));
+ return LongStream.of(1);
}LongStreamConcat
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamConcat")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamConcat).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamConcat() {
- return Streams.concat(LongStream.of(1), LongStream.of(2));
+ return LongStream.concat(LongStream.of(1), LongStream.of(2));
}LongStreamFlatMapFilter
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamFlatMapFilter")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamFlatMapFilter).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamFlatMapFilter() {
- return LongStream.of(1).flatMap(v -> LongStream.of(v * v).filter(n -> n > 1));
+ return LongStream.of(1).flatMap(v -> LongStream.of(v * v)).filter(n -> n > 1);
}StreamFlatMapToLongFilter
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamFlatMapToLongFilter")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$StreamFlatMapToLongFilter).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testStreamFlatMapToLongFilter() {
- return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v).filter(n -> n > 1));
+ return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v)).filter(n -> n > 1);
}LongStreamFlatMapMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamFlatMapMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamFlatMapMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamFlatMapMap() {
- return LongStream.of(1).flatMap(v -> LongStream.of(v * v).map(n -> n * 1));
+ return LongStream.of(1).flatMap(v -> LongStream.of(v * v)).map(n -> n * 1);
}StreamFlatMapToLongMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamFlatMapToLongMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$StreamFlatMapToLongMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testStreamFlatMapToLongMap() {
- return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v).map(n -> n * 1));
+ return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v)).map(n -> n * 1);
}LongStreamFlatMapFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamFlatMapFlatMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamFlatMapFlatMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamFlatMapFlatMap() {
- return LongStream.of(1).flatMap(v -> LongStream.of(v * v).flatMap(LongStream::of));
+ return LongStream.of(1).flatMap(v -> LongStream.of(v * v)).flatMap(LongStream::of);
}StreamFlatMapToLongFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("StreamFlatMapToLongFlatMap")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$StreamFlatMapToLongFlatMap).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testStreamFlatMapToLongFlatMap() {
- return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v).flatMap(LongStream::of));
+ return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v)).flatMap(LongStream::of);
}LongStreamFilterSorted
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamFilterSorted")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamFilterSorted).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamFilterSorted() {
- return LongStream.of(1, 4, 3, 2).sorted().filter(l -> l % 2 == 0);
+ return LongStream.of(1, 4, 3, 2).filter(l -> l % 2 == 0).sorted();
}LongStreamFindAnyIsEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamFindAnyIsEmpty")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamFindAnyIsEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testLongStreamFindAnyIsEmpty() {
return ImmutableSet.of(
- LongStream.of(1).count() == 0,
- LongStream.of(2).count() <= 0,
- LongStream.of(3).count() < 1,
- LongStream.of(4).findFirst().isEmpty());
+ LongStream.of(1).findAny().isEmpty(),
+ LongStream.of(2).findAny().isEmpty(),
+ LongStream.of(3).findAny().isEmpty(),
+ LongStream.of(4).findAny().isEmpty());
}LongStreamFindAnyIsPresent
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamFindAnyIsPresent")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamFindAnyIsPresent).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testLongStreamFindAnyIsPresent() {
return ImmutableSet.of(
- LongStream.of(1).count() != 0,
- LongStream.of(2).count() > 0,
- LongStream.of(3).count() >= 1,
- LongStream.of(4).findFirst().isPresent());
+ LongStream.of(1).findAny().isPresent(),
+ LongStream.of(2).findAny().isPresent(),
+ LongStream.of(3).findAny().isPresent(),
+ LongStream.of(4).findAny().isPresent());
}LongStreamMin
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamMin")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamMin).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
OptionalLong testLongStreamMin() {
- return LongStream.of(1).sorted().findFirst();
+ return LongStream.of(1).min();
}LongStreamNoneMatchWithLongPredicate
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamNoneMatchWithLongPredicate")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamNoneMatchWithLongPredicate).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testLongStreamNoneMatchWithLongPredicate() {
LongPredicate pred = i -> i > 0;
return ImmutableSet.of(
- !LongStream.of(1).anyMatch(n -> n > 1),
- LongStream.of(2).allMatch(pred.negate()),
- LongStream.of(3).filter(pred).findAny().isEmpty());
+ LongStream.of(1).noneMatch(n -> n > 1),
+ LongStream.of(2).noneMatch(pred),
+ LongStream.of(3).noneMatch(pred));
}LongStreamNoneMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamNoneMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamNoneMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testLongStreamNoneMatch() {
- return LongStream.of(1).allMatch(n -> !(n > 1));
+ return LongStream.of(1).noneMatch(n -> n > 1);
}LongStreamAnyMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamAnyMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamAnyMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testLongStreamAnyMatch() {
return ImmutableSet.of(
- !LongStream.of(1).noneMatch(n -> n > 1),
- LongStream.of(2).filter(n -> n > 2).findAny().isPresent());
+ LongStream.of(1).anyMatch(n -> n > 1), LongStream.of(2).anyMatch(n -> n > 2));
}LongStreamAllMatchWithLongPredicate
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamAllMatchWithLongPredicate")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamAllMatchWithLongPredicate).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testLongStreamAllMatchWithLongPredicate() {
LongPredicate pred = i -> i > 0;
- return LongStream.of(1).noneMatch(pred.negate());
+ return LongStream.of(1).allMatch(pred);
}LongStreamAllMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamAllMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamAllMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testLongStreamAllMatch() {
- return LongStream.of(1).noneMatch(n -> !(n > 1));
+ return LongStream.of(1).allMatch(n -> n > 1);
}LongStreamTakeWhile
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamTakeWhile")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamTakeWhile).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamTakeWhile() {
- return LongStream.of(1, 2, 3).takeWhile(i -> i < 2).filter(i -> i < 2);
+ return LongStream.of(1, 2, 3).takeWhile(i -> i < 2);
}