LongStreamRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$).*
as compiler argument.
Table of contents
- LongStreamClosedOpenRange
- ConcatOneLongStream
- ConcatTwoLongStreams
- FilterOuterLongStreamAfterFlatMap
- FilterOuterStreamAfterFlatMapToLong
- MapOuterLongStreamAfterFlatMap
- MapOuterStreamAfterFlatMapToLong
- FlatMapOuterLongStreamAfterFlatMap
- FlatMapOuterStreamAfterFlatMapToLong
- LongStreamFilterSorted
- LongStreamIsEmpty
- LongStreamIsNotEmpty
- LongStreamMin
- LongStreamNoneMatch
- LongStreamNoneMatch2
- LongStreamAnyMatch
- LongStreamAllMatch
- LongStreamAllMatch2
- LongStreamTakeWhile
LongStreamClosedOpenRange
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamClosedOpenRange")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamClosedOpenRange).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testLongStreamClosedOpenRange() {
- return LongStream.rangeClosed(0, 42 - 1);
+ return LongStream.range(0, 42);
}
ConcatOneLongStream
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ConcatOneLongStream")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$ConcatOneLongStream).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testConcatOneLongStream() {
- return Streams.concat(LongStream.of(1));
+ return LongStream.of(1);
}
ConcatTwoLongStreams
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ConcatTwoLongStreams")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$ConcatTwoLongStreams).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testConcatTwoLongStreams() {
- return Streams.concat(LongStream.of(1), LongStream.of(2));
+ return LongStream.concat(LongStream.of(1), LongStream.of(2));
}
FilterOuterLongStreamAfterFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FilterOuterLongStreamAfterFlatMap")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$FilterOuterLongStreamAfterFlatMap).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testFilterOuterLongStreamAfterFlatMap() {
- 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);
}
FilterOuterStreamAfterFlatMapToLong
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FilterOuterStreamAfterFlatMapToLong")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$FilterOuterStreamAfterFlatMapToLong).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testFilterOuterStreamAfterFlatMapToLong() {
- 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);
}
MapOuterLongStreamAfterFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapOuterLongStreamAfterFlatMap")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$MapOuterLongStreamAfterFlatMap).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testMapOuterLongStreamAfterFlatMap() {
- 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);
}
MapOuterStreamAfterFlatMapToLong
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("MapOuterStreamAfterFlatMapToLong")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$MapOuterStreamAfterFlatMapToLong).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testMapOuterStreamAfterFlatMapToLong() {
- 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);
}
FlatMapOuterLongStreamAfterFlatMap
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FlatMapOuterLongStreamAfterFlatMap")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$FlatMapOuterLongStreamAfterFlatMap).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testFlatMapOuterLongStreamAfterFlatMap() {
- 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);
}
FlatMapOuterStreamAfterFlatMapToLong
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FlatMapOuterStreamAfterFlatMapToLong")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$FlatMapOuterStreamAfterFlatMapToLong).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
LongStream testFlatMapOuterStreamAfterFlatMapToLong() {
- 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();
}
LongStreamIsEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamIsEmpty")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamIsEmpty).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testLongStreamIsEmpty() {
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());
}
LongStreamIsNotEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamIsNotEmpty")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamIsNotEmpty).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testLongStreamIsNotEmpty() {
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();
}
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.
ImmutableSet<Boolean> testLongStreamNoneMatch() {
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));
}
LongStreamNoneMatch2
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamNoneMatch2")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamNoneMatch2).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testLongStreamNoneMatch2() {
- 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));
}
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() {
LongPredicate pred = i -> i > 0;
- return LongStream.of(1).noneMatch(pred.negate());
+ return LongStream.of(1).allMatch(pred);
}
LongStreamAllMatch2
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("LongStreamAllMatch2")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!LongStreamRules\$LongStreamAllMatch2).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
boolean testLongStreamAllMatch2() {
- 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);
}