This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit 799e3cd51b082135ff423d948ad4fa2dfbc44aba Author: Baljit Singh <balsi...@ge.com> AuthorDate: Wed Jul 1 11:44:47 2020 -0400 Simplify Stream usage --- .../commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java | 5 +++-- .../geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java | 5 ++--- .../commons/geometry/euclidean/threed/RegionBSPTree3DTest.java | 4 ++-- .../geometry/euclidean/threed/rotation/QuaternionRotationTest.java | 4 ++-- .../apache/commons/geometry/spherical/twod/BoundarySource2STest.java | 3 ++- .../apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java index 0db5a06..63afc97 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.stream.StreamSupport; import org.apache.commons.geometry.core.Transform; @@ -725,7 +726,7 @@ public class AbstractBSPTreeTest { final TestLineSegment d = new TestLineSegment(1, 1, -1, 1); final TestLineSegment e = new TestLineSegment(-1, 1, -1, -1); - final BoundarySource<TestLineSegment> src = () -> Arrays.asList(a, b, c, d, e).stream(); + final BoundarySource<TestLineSegment> src = () -> Stream.of(a, b, c, d, e); // act tree.insert(src); @@ -758,7 +759,7 @@ public class AbstractBSPTreeTest { // arrange final TestBSPTree tree = new TestBSPTree(); - final BoundarySource<TestLineSegment> src = () -> new ArrayList<TestLineSegment>().stream(); + final BoundarySource<TestLineSegment> src = Stream::empty; // act tree.insert(src); diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java index b039d69..0d98480 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Stream; import org.apache.commons.geometry.core.GeometryTestUtils; import org.apache.commons.geometry.core.RegionLocation; @@ -147,9 +148,7 @@ public class AbstractRegionBSPTreeTest { @Test public void testInsert_boundarySource_mixedCutRules() { // arrange - final Function<TestLineSegment, BoundarySource<TestLineSegment>> factory = seg -> { - return () -> Arrays.asList(seg).stream(); - }; + final Function<TestLineSegment, BoundarySource<TestLineSegment>> factory = seg -> () -> Stream.of(seg); // act/assert checkMixedCutRuleInsertion(segs -> { diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java index 4cd05b8..9ce06b3 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java @@ -339,8 +339,8 @@ public class RegionBSPTree3DTest { final RegionBSPTree3D empty = RegionBSPTree3D.empty(); // act/assert - Assert.assertEquals(0, full.triangleStream().collect(Collectors.toList()).size()); - Assert.assertEquals(0, empty.triangleStream().collect(Collectors.toList()).size()); + Assert.assertEquals(0, full.triangleStream().count()); + Assert.assertEquals(0, empty.triangleStream().count()); } @Test diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java index ea288e9..7c39ffd 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java @@ -16,11 +16,11 @@ */ package org.apache.commons.geometry.euclidean.threed.rotation; -import java.util.Arrays; import java.util.List; import java.util.function.DoubleFunction; import java.util.function.UnaryOperator; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.commons.geometry.core.GeometryTestUtils; import org.apache.commons.geometry.core.internal.SimpleTupleFormat; @@ -967,7 +967,7 @@ public class QuaternionRotationTest { } private List<AxisSequence> getAxes(final AxisSequenceType type) { - return Arrays.asList(AxisSequence.values()).stream() + return Stream.of(AxisSequence.values()) .filter(a -> type.equals(a.getType())) .collect(Collectors.toList()); } diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundarySource2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundarySource2STest.java index d0adf1c..f7f825c 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundarySource2STest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundarySource2STest.java @@ -19,6 +19,7 @@ package org.apache.commons.geometry.spherical.twod; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import org.apache.commons.geometry.core.precision.DoublePrecisionContext; import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext; @@ -50,7 +51,7 @@ public class BoundarySource2STest { @Test public void testToTree_noBoundaries() { // act - final BoundarySource2S src = () -> new ArrayList<GreatArc>().stream(); + final BoundarySource2S src = Stream::empty; // act final RegionBSPTree2S tree = src.toTree(); diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java index c8f3312..37e3fa7 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java @@ -317,7 +317,7 @@ public class RegionBSPTree2STest { // assert Assert.assertEquals(2, result.size()); - final double size = result.stream().collect(Collectors.summingDouble(a -> a.getSize())); + final double size = result.stream().mapToDouble(ConvexArea2S::getSize).sum(); Assert.assertEquals(PlaneAngleRadians.TWO_PI, size, TEST_EPS); } @@ -338,7 +338,7 @@ public class RegionBSPTree2STest { // assert Assert.assertEquals(2, result.size()); - final double size = result.stream().collect(Collectors.summingDouble(a -> a.getSize())); + final double size = result.stream().mapToDouble(ConvexArea2S::getSize).sum(); Assert.assertEquals(PlaneAngleRadians.TWO_PI, size, TEST_EPS); }