Skip to main content Link Search Menu Expand Document (external link)

DoubleStreamRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules.*)) as compiler argument.

Table of contents
  1. ConcatOneDoubleStream
  2. ConcatTwoDoubleStreams
  3. FilterOuterDoubleStreamAfterFlatMap
  4. FilterOuterStreamAfterFlatMapToDouble
  5. MapOuterDoubleStreamAfterFlatMap
  6. MapOuterStreamAfterFlatMapToDouble
  7. FlatMapOuterDoubleStreamAfterFlatMap
  8. FlatMapOuterStreamAfterFlatMapToDouble
  9. DoubleStreamFilterSorted
  10. DoubleStreamIsEmpty
  11. DoubleStreamIsNotEmpty
  12. DoubleStreamMin
  13. DoubleStreamNoneMatch
  14. DoubleStreamNoneMatch2
  15. DoubleStreamAnyMatch
  16. DoubleStreamAllMatch
  17. DoubleStreamAllMatch2

ConcatOneDoubleStream

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("ConcatOneDoubleStream") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.ConcatOneDoubleStream)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testConcatOneDoubleStream() {
-    return Streams.concat(DoubleStream.of(1));
+    return DoubleStream.of(1);
   }

ConcatTwoDoubleStreams

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("ConcatTwoDoubleStreams") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.ConcatTwoDoubleStreams)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testConcatTwoDoubleStreams() {
-    return Streams.concat(DoubleStream.of(1), DoubleStream.of(2));
+    return DoubleStream.concat(DoubleStream.of(1), DoubleStream.of(2));
   }

FilterOuterDoubleStreamAfterFlatMap

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FilterOuterDoubleStreamAfterFlatMap") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.FilterOuterDoubleStreamAfterFlatMap)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testFilterOuterDoubleStreamAfterFlatMap() {
-    return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v).filter(n -> n > 1));
+    return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v)).filter(n -> n > 1);
   }

FilterOuterStreamAfterFlatMapToDouble

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FilterOuterStreamAfterFlatMapToDouble") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.FilterOuterStreamAfterFlatMapToDouble)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testFilterOuterStreamAfterFlatMapToDouble() {
-    return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v).filter(n -> n > 1));
+    return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v)).filter(n -> n > 1);
   }

MapOuterDoubleStreamAfterFlatMap

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("MapOuterDoubleStreamAfterFlatMap") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.MapOuterDoubleStreamAfterFlatMap)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testMapOuterDoubleStreamAfterFlatMap() {
-    return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v).map(n -> n * 1));
+    return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v)).map(n -> n * 1);
   }

MapOuterStreamAfterFlatMapToDouble

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("MapOuterStreamAfterFlatMapToDouble") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.MapOuterStreamAfterFlatMapToDouble)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testMapOuterStreamAfterFlatMapToDouble() {
-    return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v).map(n -> n * 1));
+    return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v)).map(n -> n * 1);
   }

FlatMapOuterDoubleStreamAfterFlatMap

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FlatMapOuterDoubleStreamAfterFlatMap") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.FlatMapOuterDoubleStreamAfterFlatMap)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testFlatMapOuterDoubleStreamAfterFlatMap() {
-    return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v).flatMap(DoubleStream::of));
+    return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v)).flatMap(DoubleStream::of);
   }

FlatMapOuterStreamAfterFlatMapToDouble

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FlatMapOuterStreamAfterFlatMapToDouble") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.FlatMapOuterStreamAfterFlatMapToDouble)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testFlatMapOuterStreamAfterFlatMapToDouble() {
-    return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v).flatMap(DoubleStream::of));
+    return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v)).flatMap(DoubleStream::of);
   }

DoubleStreamFilterSorted

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamFilterSorted") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamFilterSorted)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 DoubleStream testDoubleStreamFilterSorted() {
-    return DoubleStream.of(1, 4, 3, 2).sorted().filter(d -> d % 2 == 0);
+    return DoubleStream.of(1, 4, 3, 2).filter(d -> d % 2 == 0).sorted();
   }

DoubleStreamIsEmpty

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamIsEmpty") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamIsEmpty)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testDoubleStreamIsEmpty() {
     return ImmutableSet.of(
-        DoubleStream.of(1).count() == 0,
-        DoubleStream.of(2).count() <= 0,
-        DoubleStream.of(3).count() < 1,
-        DoubleStream.of(4).findFirst().isEmpty());
+        DoubleStream.of(1).findAny().isEmpty(),
+        DoubleStream.of(2).findAny().isEmpty(),
+        DoubleStream.of(3).findAny().isEmpty(),
+        DoubleStream.of(4).findAny().isEmpty());
   }

DoubleStreamIsNotEmpty

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamIsNotEmpty") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamIsNotEmpty)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testDoubleStreamIsNotEmpty() {
     return ImmutableSet.of(
-        DoubleStream.of(1).count() != 0,
-        DoubleStream.of(2).count() > 0,
-        DoubleStream.of(3).count() >= 1,
-        DoubleStream.of(4).findFirst().isPresent());
+        DoubleStream.of(1).findAny().isPresent(),
+        DoubleStream.of(2).findAny().isPresent(),
+        DoubleStream.of(3).findAny().isPresent(),
+        DoubleStream.of(4).findAny().isPresent());
   }

DoubleStreamMin

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamMin") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamMin)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 OptionalDouble testDoubleStreamMin() {
-    return DoubleStream.of(1).sorted().findFirst();
+    return DoubleStream.of(1).min();
   }

DoubleStreamNoneMatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamNoneMatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamNoneMatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testDoubleStreamNoneMatch() {
     DoublePredicate pred = i -> i > 0;
     return ImmutableSet.of(
-        !DoubleStream.of(1).anyMatch(n -> n > 1),
-        DoubleStream.of(2).allMatch(pred.negate()),
-        DoubleStream.of(3).filter(pred).findAny().isEmpty());
+        DoubleStream.of(1).noneMatch(n -> n > 1),
+        DoubleStream.of(2).noneMatch(pred),
+        DoubleStream.of(3).noneMatch(pred));
   }

DoubleStreamNoneMatch2

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamNoneMatch2") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamNoneMatch2)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 boolean testDoubleStreamNoneMatch2() {
-    return DoubleStream.of(1).allMatch(n -> !(n > 1));
+    return DoubleStream.of(1).noneMatch(n -> n > 1);
   }

DoubleStreamAnyMatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamAnyMatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamAnyMatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testDoubleStreamAnyMatch() {
     return ImmutableSet.of(
-        !DoubleStream.of(1).noneMatch(n -> n > 1),
-        DoubleStream.of(2).filter(n -> n > 2).findAny().isPresent());
+        DoubleStream.of(1).anyMatch(n -> n > 1), DoubleStream.of(2).anyMatch(n -> n > 2));
   }

DoubleStreamAllMatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamAllMatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamAllMatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 boolean testDoubleStreamAllMatch() {
     DoublePredicate pred = i -> i > 0;
-    return DoubleStream.of(1).noneMatch(pred.negate());
+    return DoubleStream.of(1).allMatch(pred);
   }

DoubleStreamAllMatch2

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DoubleStreamAllMatch2") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(DoubleStreamRules\.DoubleStreamAllMatch2)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 boolean testDoubleStreamAllMatch2() {
-    return DoubleStream.of(1).noneMatch(n -> !(n > 1));
+    return DoubleStream.of(1).allMatch(n -> n > 1);
   }

Copyright © 2017-2023 Picnic Technologies BV