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 9718cfdd9a46e78c018d4d0d2f44caa46444587d
Author: Baljit Singh <balsi...@ge.com>
AuthorDate: Wed Jul 1 12:05:27 2020 -0400

    Simplify lambda usage
---
 .../geometry/euclidean/oned/RegionBSPTree1D.java   |  2 +-
 .../geometry/euclidean/oned/Vector1DTest.java      | 12 +++-----
 .../geometry/euclidean/threed/Vector3DTest.java    | 36 ++++++++--------------
 .../geometry/euclidean/twod/Vector2DTest.java      | 36 ++++++++--------------
 .../geometry/euclidean/twod/path/LinePathTest.java | 10 +++---
 .../geometry/spherical/oned/RegionBSPTree1S.java   |  2 +-
 .../spherical/twod/BoundarySource2STest.java       |  7 ++---
 7 files changed, 37 insertions(+), 68 deletions(-)

diff --git 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
index a89ca46..cf15c4e 100644
--- 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
+++ 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
@@ -36,7 +36,7 @@ import 
org.apache.commons.geometry.core.partitioning.bsp.RegionCutRule;
 public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, 
RegionBSPTree1D.RegionNode1D> {
     /** Comparator used to sort BoundaryPairs by ascending location.  */
     private static final Comparator<BoundaryPair> BOUNDARY_PAIR_COMPARATOR =
-        (a, b) -> Double.compare(a.getMinValue(), b.getMinValue());
+            Comparator.comparingDouble(BoundaryPair::getMinValue);
 
     /** Create a new, empty region.
      */
diff --git 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index a138cd1..98cc9fb 100644
--- 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -45,14 +45,10 @@ public class Vector1DTest {
     @Test
     public void testConstants_normalize() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector1D.NaN.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.POSITIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.NEGATIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector1D.ZERO::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector1D.NaN::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector1D.POSITIVE_INFINITY::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector1D.NEGATIVE_INFINITY::normalize, 
IllegalArgumentException.class);
 
         Assert.assertSame(Vector1D.Unit.PLUS, Vector1D.Unit.PLUS.normalize());
         Assert.assertSame(Vector1D.Unit.MINUS, 
Vector1D.Unit.MINUS.normalize());
diff --git 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index 03c018a..07252dc 100644
--- 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -59,14 +59,10 @@ public class Vector3DTest {
     @Test
     public void testConstants_normalize() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector3D.NaN.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector3D.POSITIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector3D.NEGATIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.ZERO::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.NaN::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.POSITIVE_INFINITY::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.NEGATIVE_INFINITY::normalize, 
IllegalArgumentException.class);
 
         Assert.assertSame(Vector3D.Unit.PLUS_X, 
Vector3D.Unit.PLUS_X.normalize());
         Assert.assertSame(Vector3D.Unit.MINUS_X, 
Vector3D.Unit.MINUS_X.normalize());
@@ -408,14 +404,10 @@ public class Vector3DTest {
     @Test
     public void testNormalize_illegalNorm() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector3D.NaN.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector3D.POSITIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector3D.NEGATIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.ZERO::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.NaN::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.POSITIVE_INFINITY::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.NEGATIVE_INFINITY::normalize, 
IllegalArgumentException.class);
     }
 
     @Test
@@ -447,14 +439,10 @@ public class Vector3DTest {
     @Test
     public void testOrthogonal_illegalNorm() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.orthogonal(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector3D.NaN.orthogonal(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector3D.POSITIVE_INFINITY.orthogonal(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector3D.NEGATIVE_INFINITY.orthogonal(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.ZERO::orthogonal, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.NaN::orthogonal, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.POSITIVE_INFINITY::orthogonal, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector3D.NEGATIVE_INFINITY::orthogonal, 
IllegalArgumentException.class);
     }
 
     @Test
diff --git 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index e0df248..d68d058 100644
--- 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -50,14 +50,10 @@ public class Vector2DTest {
     @Test
     public void testConstants_normalize() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector2D.NaN.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector2D.POSITIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector2D.NEGATIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.ZERO::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.NaN::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.POSITIVE_INFINITY::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.NEGATIVE_INFINITY::normalize, 
IllegalArgumentException.class);
 
         Assert.assertSame(Vector2D.Unit.PLUS_X, 
Vector2D.Unit.PLUS_X.normalize());
         Assert.assertSame(Vector2D.Unit.MINUS_X, 
Vector2D.Unit.MINUS_X.normalize());
@@ -335,14 +331,10 @@ public class Vector2DTest {
     @Test
     public void testNormalize_illegalNorm() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector2D.NaN.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector2D.POSITIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector2D.NEGATIVE_INFINITY.normalize(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.ZERO::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.NaN::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.POSITIVE_INFINITY::normalize, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.NEGATIVE_INFINITY::normalize, 
IllegalArgumentException.class);
     }
 
     @Test
@@ -484,14 +476,10 @@ public class Vector2DTest {
     @Test
     public void testOrthogonal_illegalNorm() {
         // act/assert
-        GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.orthogonal(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> Vector2D.NaN.orthogonal(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector2D.POSITIVE_INFINITY.orthogonal(),
-                IllegalArgumentException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector2D.NEGATIVE_INFINITY.orthogonal(),
-                IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.ZERO::orthogonal, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.NaN::orthogonal, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.POSITIVE_INFINITY::orthogonal, 
IllegalArgumentException.class);
+        GeometryTestUtils.assertThrows(Vector2D.NEGATIVE_INFINITY::orthogonal, 
IllegalArgumentException.class);
     }
 
     @Test
diff --git 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
index 13210b1..016f827 100644
--- 
a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
+++ 
b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
@@ -1288,9 +1288,8 @@ public class LinePathTest {
             .append(Vector2D.of(1, 1));
 
         // act/assert
-        GeometryTestUtils.assertThrows(() -> {
-            builder.close();
-        }, IllegalStateException.class, "Unable to close line path: line path 
is infinite");
+        GeometryTestUtils.assertThrows(builder::close, 
IllegalStateException.class,
+                "Unable to close line path: line path is infinite");
     }
 
     @Test
@@ -1305,9 +1304,8 @@ public class LinePathTest {
                 .rayFrom(0));
 
         // act/assert
-        GeometryTestUtils.assertThrows(() -> {
-            builder.close();
-        }, IllegalStateException.class, "Unable to close line path: line path 
is infinite");
+        GeometryTestUtils.assertThrows(builder::close, 
IllegalStateException.class,
+                "Unable to close line path: line path is infinite");
     }
 
     @Test
diff --git 
a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
 
b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
index b0e6883..bb1a290 100644
--- 
a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
+++ 
b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
@@ -38,7 +38,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
 public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, 
RegionBSPTree1S.RegionNode1S> {
     /** Comparator used to sort BoundaryPairs by ascending azimuth.  */
     private static final Comparator<BoundaryPair> BOUNDARY_PAIR_COMPARATOR =
-        (a, b) -> Double.compare(a.getMinValue(), b.getMinValue());
+            Comparator.comparingDouble(BoundaryPair::getMinValue);
 
     /** Create a new, empty instance.
      */
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 f7f825c..3cee81d 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
@@ -30,14 +30,13 @@ public class BoundarySource2STest {
 
     private static final double TEST_EPS = 1e-10;
 
-    private static final DoublePrecisionContext TEST_PRECISION =
-            new EpsilonDoublePrecisionContext(TEST_EPS);
+    private static final DoublePrecisionContext TEST_PRECISION = new 
EpsilonDoublePrecisionContext(TEST_EPS);
 
     @Test
     public void testToTree() {
         // act
-        final List<GreatArc> arcs = 
Arrays.asList(GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, 
TEST_PRECISION));
-        final BoundarySource2S src = () -> arcs.stream();
+        final BoundarySource2S src = () -> Stream.of(
+                GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, 
TEST_PRECISION));
 
         // act
         final RegionBSPTree2S tree = src.toTree();

Reply via email to