commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [commons-geometry] 09/12: Prefer method reference (over lambda).
Date Thu, 28 Nov 2019 14:12:17 GMT
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 0dd2ad4964ef2d85973258858e3f586d573c8e27
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
AuthorDate: Thu Nov 28 14:54:23 2019 +0100

    Prefer method reference (over lambda).
    
    Reported by "sonarcloud.io".
---
 .../java/org/apache/commons/geometry/euclidean/twod/Polyline.java   | 6 +++---
 .../java/org/apache/commons/geometry/spherical/oned/Point1S.java    | 2 +-
 .../org/apache/commons/geometry/spherical/twod/ConvexArea2S.java    | 4 ++--
 3 files changed, 6 insertions(+), 6 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 236ac2e..9ef8a1c 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
@@ -172,7 +172,7 @@ public class Polyline implements Iterable<Segment> {
         if (!isEmpty()) {
             final List<Segment> transformed = segments.stream()
                     .map(s -> s.transform(transform))
-                    .collect(Collectors.toCollection(() -> new ArrayList<>()));
+                .collect(Collectors.toCollection(ArrayList::new));
 
             return new Polyline(transformed);
         }
@@ -188,8 +188,8 @@ public class Polyline implements Iterable<Segment> {
     public Polyline reverse() {
         if (!isEmpty()) {
             final List<Segment> reversed = segments.stream()
-                    .map(s -> s.reverse())
-                    .collect(Collectors.toCollection(() -> new ArrayList<>()));
+                .map(Segment::reverse)
+                .collect(Collectors.toCollection(ArrayList::new));
             Collections.reverse(reversed);
 
             return new Polyline(reversed);
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
index c3f8fbe..0f8b006 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
@@ -353,7 +353,7 @@ public final class Point1S implements Point<Point1S> {
      * @throws IllegalArgumentException if the given string has an invalid format
      */
     public static Point1S parse(final String str) {
-        return SimpleTupleFormat.getDefault().parse(str, az -> Point1S.of(az));
+        return SimpleTupleFormat.getDefault().parse(str, Point1S::of);
     }
 
     /** Compute the signed shortest distance (angular separation) between two points. The
return
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
index 36f3241..7581b90 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
@@ -258,8 +258,8 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
      */
     public static ConvexArea2S fromPath(final GreatArcPath path) {
         final List<GreatCircle> bounds = path.getArcs().stream()
-                .map(a -> a.getCircle())
-                .collect(Collectors.toList());
+            .map(GreatArc::getCircle)
+            .collect(Collectors.toList());
 
         return fromBounds(bounds);
     }


Mime
View raw message