Skip to content

Commit

Permalink
Use default value
Browse files Browse the repository at this point in the history
  • Loading branch information
kathy-t committed Jul 12, 2023
1 parent fae9e4c commit 62c9e7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static DoubleStatistics createFromStatistics(List<DoubleStatistics> stati
*/
@Override
public Double calculateMinimum(List<Double> dataPoints) {
return dataPoints.stream().mapToDouble(d -> d).min().getAsDouble();
return dataPoints.stream().mapToDouble(d -> d).min().orElse(0);
}

/**
Expand All @@ -84,7 +84,7 @@ public Double calculateMinimum(List<Double> dataPoints) {
*/
@Override
public Double calculateMaximum(List<Double> dataPoints) {
return dataPoints.stream().mapToDouble(d -> d).max().getAsDouble();
return dataPoints.stream().mapToDouble(d -> d).max().orElse(0);
}

/**
Expand All @@ -94,7 +94,7 @@ public Double calculateMaximum(List<Double> dataPoints) {
*/
@Override
public Double calculateAverage(List<Double> dataPoints) {
return dataPoints.stream().mapToDouble(d -> d).average().getAsDouble();
return dataPoints.stream().mapToDouble(d -> d).average().orElse(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static MoneyStatistics createFromStatistics(List<MoneyStatistics> statist
public Money calculateMinimum(List<Money> dataPoints) {
return dataPoints.stream()
.min(Money::compareTo)
.get();
.orElse(Money.of(0, currency));
}

/**
Expand All @@ -60,7 +60,7 @@ public Money calculateMinimum(List<Money> dataPoints) {
public Money calculateMaximum(List<Money> dataPoints) {
return dataPoints.stream()
.max(Money::compareTo)
.get();
.orElse(Money.of(0, currency));
}

/**
Expand Down

0 comments on commit 62c9e7c

Please sign in to comment.