You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/12/29 17:18:44 UTC

svn commit: r1896511 - in /poi/trunk/poi/src/main/java/org/apache/poi/ss/formula: OperatorEnum.java functions/LookupUtils.java

Author: fanningpj
Date: Wed Dec 29 17:18:44 2021
New Revision: 1896511

URL: http://svn.apache.org/viewvc?rev=1896511&view=rev
Log:
sonar issues

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
    poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java

Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java?rev=1896511&r1=1896510&r2=1896511&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java Wed Dec 29 17:18:44 2021
@@ -32,7 +32,7 @@ enum OperatorEnum {
     NO_COMPARISON(OperatorEnum::noComp, false),
     BETWEEN(OperatorEnum::between, false),
     NOT_BETWEEN(OperatorEnum::notBetween, true),
-    EQUAL(OperatorEnum::equal, false),
+    EQUAL(OperatorEnum::equalCheck, false),
     NOT_EQUAL(OperatorEnum::notEqual, true),
     GREATER_THAN(OperatorEnum::greaterThan, false),
     LESS_THAN(OperatorEnum::lessThan, false),
@@ -111,7 +111,7 @@ enum OperatorEnum {
         return cellValue.compareTo(v1) < 0 || cellValue.compareTo(v2) > 0;
     }
 
-    private static <C extends Comparable<C>> boolean equal(C cellValue, C v1, C v2) {
+    private static <C extends Comparable<C>> boolean equalCheck(C cellValue, C v1, C v2) {
         if (v1 == null) {
             if (cellValue instanceof Number) {
                 // use zero for null
@@ -121,8 +121,7 @@ enum OperatorEnum {
             } else if (cellValue instanceof Boolean) return false;
             return false; // just in case - not a typical possibility
         }
-        // need to avoid instanceof, to work around a 1.6 compiler bug
-        if (cellValue.getClass() == String.class) {
+        if (cellValue instanceof String) {
             return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
         }
         return cellValue.compareTo(v1) == 0;

Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java?rev=1896511&r1=1896510&r2=1896511&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java Wed Dec 29 17:18:44 2021
@@ -114,7 +114,7 @@ public final class LookupUtils {
 
         default Iterator<Integer> indexIterator() {
             return new Iterator<Integer>() {
-                int pos = 0;
+                private int pos = 0;
 
                 @Override
                 public boolean hasNext() {
@@ -123,7 +123,9 @@ public final class LookupUtils {
 
                 @Override
                 public Integer next() {
-                    return pos++;
+                    pos++;
+                    if (pos > getSize()) throw new NoSuchElementException();
+                    return pos;
                 }
             };
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org