You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by kh...@apache.org on 2019/06/04 20:02:29 UTC
[commons-statistics] 02/02: WIP - [STATISTICS-14] -
BigDecimalStatistics - Continued.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch STATISTICS-14
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
commit 3092c6082dbdc0e8fddf2917a10d2e854ccaff1d
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Tue Jun 4 22:02:12 2019 +0200
WIP - [STATISTICS-14] - BigDecimalStatistics - Continued.
---
.travis.yml | 7 +++----
.../descriptive/BigDecimalSummaryStatistics.java | 16 ++++++++++------
.../descriptive/BigDecimalSummaryStatisticsAssert.java | 6 ------
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 41ac734..6fe9f03 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,14 +14,13 @@
# limitations under the License.
language: java
-sudo: false
jdk:
- oraclejdk8
- openjdk8
-script:
- - mvn
+install: true
-after_success:
+script:
- mvn clean test jacoco:report coveralls:report -Ptravis-jacoco
+
diff --git a/commons-statistics-bigdecimal/src/main/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatistics.java b/commons-statistics-bigdecimal/src/main/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatistics.java
index a2625fc..ad5f05a 100644
--- a/commons-statistics-bigdecimal/src/main/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatistics.java
+++ b/commons-statistics-bigdecimal/src/main/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatistics.java
@@ -25,6 +25,10 @@ import java.util.function.Consumer;
public class BigDecimalSummaryStatistics implements Consumer<BigDecimal> {
/**
+ * The count value for zero.
+ */
+ private static final long ZERO_COUNT = 0L;
+ /**
* internal counter.
*/
private long count;
@@ -46,7 +50,7 @@ public class BigDecimalSummaryStatistics implements Consumer<BigDecimal> {
* BigDecimal#ZERO}
*/
public BigDecimalSummaryStatistics() {
- this.count = 0;
+ this.count = ZERO_COUNT;
this.sum = BigDecimal.ZERO;
this.max = null;
this.min = null;
@@ -76,9 +80,9 @@ public class BigDecimalSummaryStatistics implements Consumer<BigDecimal> {
public BigDecimalSummaryStatistics(long count, BigDecimal min, BigDecimal max,
BigDecimal sum) {
- if (count < 0L) {
+ if (count < ZERO_COUNT) {
throw new IllegalArgumentException("count must be greater or equal to zero.");
- } else if (count > 0L) {
+ } else if (count > ZERO_COUNT) {
if (min == null) {
throw new IllegalArgumentException("min is not allowed to be null.");
}
@@ -132,7 +136,7 @@ public class BigDecimalSummaryStatistics implements Consumer<BigDecimal> {
* @param other another {@code BigDecimalSummaryStatistics}
* @throws IllegalArgumentException in case of giving {@code null} for {@code value}.
*/
- public void combine(BigDecimalSummaryStatistics other) throws IllegalArgumentException {
+ public void combine(BigDecimalSummaryStatistics other) {
if (other == null) {
throw new IllegalArgumentException("other is not allowed to be null.");
}
@@ -176,7 +180,7 @@ public class BigDecimalSummaryStatistics implements Consumer<BigDecimal> {
* converted to a BigDecimal.
*/
public final BigDecimal getMin() {
- if (this.count == 0) {
+ if (this.count == ZERO_COUNT) {
throw new IllegalStateException(
"Minimum can not be calculated cause we have no values yet.");
}
@@ -192,7 +196,7 @@ public class BigDecimalSummaryStatistics implements Consumer<BigDecimal> {
* converted to a BigDecimal.
*/
public final BigDecimal getMax() {
- if (this.count == 0) {
+ if (this.count == ZERO_COUNT) {
throw new IllegalStateException(
"Maximum can not be calculated cause we have no values yet.");
}
diff --git a/commons-statistics-bigdecimal/src/test/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatisticsAssert.java b/commons-statistics-bigdecimal/src/test/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatisticsAssert.java
index 7d14dbb..79f1903 100644
--- a/commons-statistics-bigdecimal/src/test/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatisticsAssert.java
+++ b/commons-statistics-bigdecimal/src/test/java/org/apache/commons/statistics/bigdecimal/descriptive/BigDecimalSummaryStatisticsAssert.java
@@ -62,10 +62,4 @@ public class BigDecimalSummaryStatisticsAssert extends
return myself;
}
- public BigDecimalSummaryStatisticsAssert isEqualTo(BigDecimalSummaryStatistics expected) {
- System.out.println("this:" + this.getClass().getName());
-
- return null;
- }
-
}