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:23 UTC

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

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;