]> source.dussan.org Git - poi.git/commitdiff
small refactor
authorPJ Fanning <fanningpj@apache.org>
Thu, 26 May 2022 09:15:43 +0000 (09:15 +0000)
committerPJ Fanning <fanningpj@apache.org>
Thu, 26 May 2022 09:15:43 +0000 (09:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901275 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/DStdev.java
poi/src/main/java/org/apache/poi/ss/formula/functions/DVar.java

index 97bd2b31f0f8e1f45402d17fa5bdc76e3ac5aba1..7aca88a3cbfc8f4ca541658d747d04ee49bf3342 100644 (file)
@@ -30,13 +30,12 @@ import java.util.ArrayList;
  * Gets the standard deviation value of a column in an area with given conditions.
  */
 public final class DStdev implements IDStarAlgorithm {
-    private final ArrayList<Double> values = new ArrayList<>();
+    private final ArrayList<NumericValueEval> values = new ArrayList<>();
 
     @Override
     public boolean processMatch(ValueEval eval) {
         if (eval instanceof NumericValueEval) {
-            final double val = ((NumericValueEval)eval).getNumberValue();
-            values.add(val);
+            values.add((NumericValueEval) eval);
         }
         return true;
     }
@@ -45,8 +44,8 @@ public final class DStdev implements IDStarAlgorithm {
     public ValueEval getResult() {
         final double[] array = new double[values.size()];
         int pos = 0;
-        for (Double d : values) {
-            array[pos++] = d;
+        for (NumericValueEval d : values) {
+            array[pos++] = d.getNumberValue();
         }
         final double stdev = StatsLib.stdev(array);
         return new NumberEval(new BigDecimal(NumberToTextConverter.toText(stdev)).doubleValue());
index 51e72301a20c86d4c9abc5b6fe9a59201059182e..fdd6c5db827528b2411f40ef8e67b9a5b8804fbc 100644 (file)
@@ -30,13 +30,12 @@ import java.util.ArrayList;
  * Gets the variance value of a column in an area with given conditions.
  */
 public final class DVar implements IDStarAlgorithm {
-    private final ArrayList<Double> values = new ArrayList<>();
+    private final ArrayList<NumericValueEval> values = new ArrayList<>();
 
     @Override
     public boolean processMatch(ValueEval eval) {
         if (eval instanceof NumericValueEval) {
-            final double val = ((NumericValueEval)eval).getNumberValue();
-            values.add(val);
+            values.add((NumericValueEval) eval);
         }
         return true;
     }
@@ -45,8 +44,8 @@ public final class DVar implements IDStarAlgorithm {
     public ValueEval getResult() {
         final double[] array = new double[values.size()];
         int pos = 0;
-        for (Double d : values) {
-            array[pos++] = d;
+        for (NumericValueEval d : values) {
+            array[pos++] = d.getNumberValue();
         }
         final double var = StatsLib.var(array);
         return new NumberEval(new BigDecimal(NumberToTextConverter.toText(var)).doubleValue());