You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/11/26 16:07:21 UTC

[commons-geometry] branch master updated (ead72ed -> ee0b7c2)

This is an automated email from the ASF dual-hosted git repository.

erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git.


    from ead72ed  Upgrade "commons-skin".
     new 5ca8b9c  Use "diamond" operator.
     new abb8b40  Use dedicated method to check whether a "List" is empty.
     new ee0b7c2  Use more specific interface from the JDK.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/commons/geometry/core/Transform.java     |  4 ++--
 .../core/partitioning/bsp/AbstractRegionBSPTree.java         |  4 ++--
 .../geometry/core/partitioning/bsp/AttributeBSPTree.java     |  2 +-
 .../geometry/core/partition/test/TestTransform2D.java        |  6 +++---
 .../commons/geometry/euclidean/oned/FunctionTransform1D.java | 12 ++++++------
 .../org/apache/commons/geometry/euclidean/oned/Vector1D.java |  4 ++--
 .../geometry/euclidean/threed/FunctionTransform3D.java       | 12 ++++++------
 .../commons/geometry/euclidean/threed/RegionBSPTree3D.java   |  2 +-
 .../apache/commons/geometry/euclidean/threed/Vector3D.java   |  4 ++--
 .../commons/geometry/euclidean/twod/FunctionTransform2D.java | 12 ++++++------
 .../org/apache/commons/geometry/euclidean/twod/Polyline.java |  4 ++--
 .../org/apache/commons/geometry/euclidean/twod/Vector2D.java |  4 ++--
 .../geometry/euclidean/oned/FunctionTransform1DTest.java     |  4 ++--
 .../geometry/euclidean/threed/FunctionTransform3DTest.java   |  4 ++--
 .../geometry/euclidean/twod/FunctionTransform2DTest.java     |  4 ++--
 .../apache/commons/geometry/spherical/twod/GreatArcPath.java |  4 ++--
 16 files changed, 43 insertions(+), 43 deletions(-)


[commons-geometry] 01/03: Use "diamond" operator.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git

commit 5ca8b9cc6c744c656838be587f4c73873b778c4f
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Tue Nov 26 16:39:24 2019 +0100

    Use "diamond" operator.
    
    Reported by "sonarcloud.io".
---
 .../commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java | 4 ++--
 .../commons/geometry/core/partitioning/bsp/AttributeBSPTree.java      | 2 +-
 .../org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
index 9a867a8..5bce738 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
@@ -242,7 +242,7 @@ public abstract class AbstractRegionBSPTree<
             splitPlus = plus.isEmpty() ? null : plus;
         }
 
-        return new Split<T>(splitMinus, splitPlus);
+        return new Split<>(splitMinus, splitPlus);
     }
 
     /** Get the size-related properties for the region. The value is computed
@@ -498,7 +498,7 @@ public abstract class AbstractRegionBSPTree<
             }
         }
 
-        return new RegionCutBoundary<P>(insideFacing.build(), outsideFacing.build());
+        return new RegionCutBoundary<>(insideFacing.build(), outsideFacing.build());
     }
 
     /** Recursive method to characterize a convex subhyperplane with respect to the region's
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTree.java
index d7fecd6..065f08f 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTree.java
@@ -52,7 +52,7 @@ public class AttributeBSPTree<P extends Point<P>, T>
     /** {@inheritDoc} */
     @Override
     protected AttributeNode<P, T> createNode() {
-        return new AttributeNode<P, T>(this);
+        return new AttributeNode<>(this);
     }
 
     /** {@inheritDoc} */
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
index 23e5792..c2f9ebd 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
@@ -659,7 +659,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
                         sumZ * barycenterScale);
             }
 
-            return new RegionSizeProperties<Vector3D>(size, barycenter);
+            return new RegionSizeProperties<>(size, barycenter);
         }
 
         /** Add the facet contribution of the given node cut boundary. If {@code reverse} is true,


[commons-geometry] 03/03: Use more specific interface from the JDK.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git

commit ee0b7c2c6c280dd41f3e10a5108c18d549f1723e
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Tue Nov 26 17:06:13 2019 +0100

    Use more specific interface from the JDK.
    
    Reported by "soundcloud.io".
---
 .../java/org/apache/commons/geometry/core/Transform.java     |  4 ++--
 .../geometry/core/partition/test/TestTransform2D.java        |  6 +++---
 .../commons/geometry/euclidean/oned/FunctionTransform1D.java | 12 ++++++------
 .../org/apache/commons/geometry/euclidean/oned/Vector1D.java |  4 ++--
 .../geometry/euclidean/threed/FunctionTransform3D.java       | 12 ++++++------
 .../apache/commons/geometry/euclidean/threed/Vector3D.java   |  4 ++--
 .../commons/geometry/euclidean/twod/FunctionTransform2D.java | 12 ++++++------
 .../org/apache/commons/geometry/euclidean/twod/Vector2D.java |  4 ++--
 .../geometry/euclidean/oned/FunctionTransform1DTest.java     |  4 ++--
 .../geometry/euclidean/threed/FunctionTransform3DTest.java   |  4 ++--
 .../geometry/euclidean/twod/FunctionTransform2DTest.java     |  4 ++--
 11 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Transform.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Transform.java
index 7eedd67..7047fab 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Transform.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Transform.java
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.geometry.core;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 /** This interface represents an <em>inversible affine transform</em> in a space.
  * Common examples of this type of transform in Euclidean space include
@@ -44,7 +44,7 @@ import java.util.function.Function;
  * @param <P> Point implementation type
  * @see <a href="https://en.wikipedia.org/wiki/Affine_transformation">Affine Space</a>
  */
-public interface Transform<P extends Point<P>> extends Function<P, P> {
+public interface Transform<P extends Point<P>> extends UnaryOperator<P> {
 
     /** Return true if the transform preserves the orientation of the space.
      * For example, in Euclidean 2D space, this will be true for translations,
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestTransform2D.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestTransform2D.java
index 2caa2be..0321da2 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestTransform2D.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestTransform2D.java
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.geometry.core.partition.test;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.core.Transform;
 
@@ -26,7 +26,7 @@ import org.apache.commons.geometry.core.Transform;
 public class TestTransform2D implements Transform<TestPoint2D> {
 
     /** Underlying transform function. */
-    private final Function<TestPoint2D, TestPoint2D> fn;
+    private final UnaryOperator<TestPoint2D> fn;
 
     /** True if the transform preserves the handedness of the space. */
     private final boolean preservesHandedness;
@@ -34,7 +34,7 @@ public class TestTransform2D implements Transform<TestPoint2D> {
     /** Create a new instance using the given transform function.
      * @param fn transform function
      */
-    public TestTransform2D(final Function<TestPoint2D, TestPoint2D> fn) {
+    public TestTransform2D(final UnaryOperator<TestPoint2D> fn) {
         this.fn = fn;
 
         final TestPoint2D tx = fn.apply(TestPoint2D.PLUS_X);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1D.java
index 5c0ca23..056f8cc 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1D.java
@@ -16,18 +16,18 @@
  */
 package org.apache.commons.geometry.euclidean.oned;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
-/** Class that wraps a {@link Function} with the {@link Transform1D} interface.
+/** Class that wraps a {@link UnaryOperator} with the {@link Transform1D} interface.
  */
 public final class FunctionTransform1D implements Transform1D {
 
     /** Static instance representing the identity transform. */
     private static final FunctionTransform1D IDENTITY =
-            new FunctionTransform1D(Function.identity(), true, Vector1D.ZERO);
+            new FunctionTransform1D(UnaryOperator.identity(), true, Vector1D.ZERO);
 
     /** The underlying function for the transform. */
-    private final Function<Vector1D, Vector1D> fn;
+    private final UnaryOperator<Vector1D> fn;
 
     /** True if the transform preserves spatial orientation. */
     private final boolean preservesOrientation;
@@ -40,7 +40,7 @@ public final class FunctionTransform1D implements Transform1D {
      * @param preservesOrientation true if the transform preserves spatial orientation
      * @param translation the translation component of the transform
      */
-    private FunctionTransform1D(final Function<Vector1D, Vector1D> fn, final boolean preservesOrientation,
+    private FunctionTransform1D(final UnaryOperator<Vector1D> fn, final boolean preservesOrientation,
             final Vector1D translation) {
         this.fn = fn;
         this.preservesOrientation = preservesOrientation;
@@ -84,7 +84,7 @@ public final class FunctionTransform1D implements Transform1D {
      * @param fn the function to use for the transform
      * @return a new transform instance using the given function
      */
-    public static FunctionTransform1D from(final Function<Vector1D, Vector1D> fn) {
+    public static FunctionTransform1D from(final UnaryOperator<Vector1D> fn) {
         final Vector1D tOne = fn.apply(Vector1D.Unit.PLUS);
         final Vector1D tZero = fn.apply(Vector1D.ZERO);
 
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
index d62e0a6..be0f7ab 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
@@ -17,7 +17,7 @@
 package org.apache.commons.geometry.euclidean.oned;
 
 import java.util.Comparator;
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.core.Geometry;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
@@ -235,7 +235,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
      * @param fn the function to apply
      * @return the transformed vector
      */
-    public Vector1D transform(final Function<Vector1D, Vector1D> fn) {
+    public Vector1D transform(final UnaryOperator<Vector1D> fn) {
         return fn.apply(this);
     }
 
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3D.java
index 15dca12..0bd7630 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3D.java
@@ -16,20 +16,20 @@
  */
 package org.apache.commons.geometry.euclidean.threed;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.euclidean.internal.Matrices;
 
-/** Class that wraps a {@link Function} with the {@link Transform3D} interface.
+/** Class that wraps a {@link UnaryOperator} with the {@link Transform3D} interface.
  */
 public final class FunctionTransform3D implements Transform3D {
 
     /** Static instance representing the identity transform. */
     private static final FunctionTransform3D IDENTITY =
-            new FunctionTransform3D(Function.identity(), true, Vector3D.ZERO);
+            new FunctionTransform3D(UnaryOperator.identity(), true, Vector3D.ZERO);
 
     /** The underlying function for the transform. */
-    private final Function<Vector3D, Vector3D> fn;
+    private final UnaryOperator<Vector3D> fn;
 
     /** True if the transform preserves spatial orientation. */
     private final boolean preservesOrientation;
@@ -42,7 +42,7 @@ public final class FunctionTransform3D implements Transform3D {
      * @param preservesOrientation true if the transform preserves spatial orientation
      * @param translation the translation component of the transform
      */
-    private FunctionTransform3D(final Function<Vector3D, Vector3D> fn, final boolean preservesOrientation,
+    private FunctionTransform3D(final UnaryOperator<Vector3D> fn, final boolean preservesOrientation,
             final Vector3D translation) {
         this.fn = fn;
         this.preservesOrientation = preservesOrientation;
@@ -88,7 +88,7 @@ public final class FunctionTransform3D implements Transform3D {
      * @param fn the function to use for the transform
      * @return a new transform instance using the given function
      */
-    public static FunctionTransform3D from(final Function<Vector3D, Vector3D> fn) {
+    public static FunctionTransform3D from(final UnaryOperator<Vector3D> fn) {
         final Vector3D tPlusX = fn.apply(Vector3D.Unit.PLUS_X);
         final Vector3D tPlusY = fn.apply(Vector3D.Unit.PLUS_Y);
         final Vector3D tPlusZ = fn.apply(Vector3D.Unit.PLUS_Z);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
index da6f7a6..6678b04 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
@@ -17,7 +17,7 @@
 package org.apache.commons.geometry.euclidean.threed;
 
 import java.util.Comparator;
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.core.internal.DoubleFunction3N;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
@@ -377,7 +377,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
      * @param fn the function to apply
      * @return the transformed vector
      */
-    public Vector3D transform(final Function<Vector3D, Vector3D> fn) {
+    public Vector3D transform(final UnaryOperator<Vector3D> fn) {
         return fn.apply(this);
     }
 
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2D.java
index 7062f1c..15fc7bb 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2D.java
@@ -16,20 +16,20 @@
  */
 package org.apache.commons.geometry.euclidean.twod;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.euclidean.internal.Matrices;
 
-/** Class that wraps a {@link Function} with the {@link Transform2D} interface.
+/** Class that wraps a {@link UnaryOperator} with the {@link Transform2D} interface.
  */
 public final class FunctionTransform2D implements Transform2D {
 
     /** Static instance representing the identity transform. */
     private static final FunctionTransform2D IDENTITY =
-            new FunctionTransform2D(Function.identity(), true, Vector2D.ZERO);
+            new FunctionTransform2D(UnaryOperator.identity(), true, Vector2D.ZERO);
 
     /** The underlying function for the transform. */
-    private final Function<Vector2D, Vector2D> fn;
+    private final UnaryOperator<Vector2D> fn;
 
     /** True if the transform preserves spatial orientation. */
     private final boolean preservesOrientation;
@@ -42,7 +42,7 @@ public final class FunctionTransform2D implements Transform2D {
      * @param preservesOrientation true if the transform preserves spatial orientation
      * @param translation the translation component of the transform
      */
-    private FunctionTransform2D(final Function<Vector2D, Vector2D> fn, final boolean preservesOrientation,
+    private FunctionTransform2D(final UnaryOperator<Vector2D> fn, final boolean preservesOrientation,
             final Vector2D translation) {
         this.fn = fn;
         this.preservesOrientation = preservesOrientation;
@@ -87,7 +87,7 @@ public final class FunctionTransform2D implements Transform2D {
      * @param fn the function to use for the transform
      * @return a new transform instance using the given function
      */
-    public static FunctionTransform2D from(final Function<Vector2D, Vector2D> fn) {
+    public static FunctionTransform2D from(final UnaryOperator<Vector2D> fn) {
         final Vector2D tPlusX = fn.apply(Vector2D.Unit.PLUS_X);
         final Vector2D tPlusY = fn.apply(Vector2D.Unit.PLUS_Y);
         final Vector2D tZero = fn.apply(Vector2D.ZERO);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
index 6e60fcf..868148d 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
@@ -17,7 +17,7 @@
 package org.apache.commons.geometry.euclidean.twod;
 
 import java.util.Comparator;
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.core.internal.DoubleFunction2N;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
@@ -321,7 +321,7 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
      * @param fn the function to apply
      * @return the transformed vector
      */
-    public Vector2D transform(final Function<Vector2D, Vector2D> fn) {
+    public Vector2D transform(final UnaryOperator<Vector2D> fn) {
         return fn.apply(this);
     }
 
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java
index af6b378..779b23a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.geometry.euclidean.oned;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
 import org.junit.Assert;
@@ -52,7 +52,7 @@ public class FunctionTransform1DTest {
         Vector1D p2 = Vector1D.of(-1);
 
         // act
-        Transform1D t = FunctionTransform1D.from(Function.identity());
+        Transform1D t = FunctionTransform1D.from(UnaryOperator.identity());
 
         // assert
         Assert.assertTrue(t.preservesOrientation());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java
index cc32706..da1e25e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.geometry.euclidean.threed;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
 import org.junit.Assert;
@@ -52,7 +52,7 @@ public class FunctionTransform3DTest {
         Vector3D p2 = Vector3D.of(-1, -1, -1);
 
         // act
-        FunctionTransform3D t = FunctionTransform3D.from(Function.identity());
+        FunctionTransform3D t = FunctionTransform3D.from(UnaryOperator.identity());
 
         // assert
         Assert.assertTrue(t.preservesOrientation());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java
index 845b187..17cfd90 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.geometry.euclidean.twod;
 
-import java.util.function.Function;
+import java.util.function.UnaryOperator;
 
 import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
 import org.junit.Assert;
@@ -52,7 +52,7 @@ public class FunctionTransform2DTest {
         Vector2D p2 = Vector2D.of(-1, -1);
 
         // act
-        FunctionTransform2D t = FunctionTransform2D.from(Function.identity());
+        FunctionTransform2D t = FunctionTransform2D.from(UnaryOperator.identity());
 
         // assert
         Assert.assertTrue(t.preservesOrientation());


[commons-geometry] 02/03: Use dedicated method to check whether a "List" is empty.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git

commit abb8b40bd0c73fdc6e1dae747c3cb416899120ff
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Tue Nov 26 16:46:33 2019 +0100

    Use dedicated method to check whether a "List" is empty.
    
    Reported by "sonarcloud.io".
---
 .../java/org/apache/commons/geometry/euclidean/twod/Polyline.java     | 4 ++--
 .../java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java
index 1722934..15d5c3a 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java
@@ -814,7 +814,7 @@ public class Polyline implements Iterable<Segment>, Serializable {
          * @return the first item from the given list or null if it does not exist
          */
         private Segment getFirst(final List<Segment> list) {
-            if (list != null && list.size() > 0) {
+            if (list != null && !list.isEmpty()) {
                 return list.get(0);
             }
             return null;
@@ -826,7 +826,7 @@ public class Polyline implements Iterable<Segment>, Serializable {
          * @return the last item from the given list or null if it does not exist
          */
         private Segment getLast(final List<Segment> list) {
-            if (list != null && list.size() > 0) {
+            if (list != null && !list.isEmpty()) {
                 return list.get(list.size() - 1);
             }
             return null;
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java
index 87cbd3b..7178e6a 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java
@@ -667,7 +667,7 @@ public final class GreatArcPath implements Iterable<GreatArc>, Serializable {
          * @return the first item from the given list or null if it does not exist
          */
         private GreatArc getFirst(final List<GreatArc> list) {
-            if (list != null && list.size() > 0) {
+            if (list != null && !list.isEmpty()) {
                 return list.get(0);
             }
             return null;
@@ -679,7 +679,7 @@ public final class GreatArcPath implements Iterable<GreatArc>, Serializable {
          * @return the last item from the given list or null if it does not exist
          */
         private GreatArc getLast(final List<GreatArc> list) {
-            if (list != null && list.size() > 0) {
+            if (list != null && !list.isEmpty()) {
                 return list.get(list.size() - 1);
             }
             return null;