edit min and max

This commit is contained in:
sam 2023-04-03 22:47:12 +04:00
parent c06688d744
commit 682370f3da

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class TimeSeries {
@ -90,14 +91,14 @@ public class TimeSeries {
public TimeSeriesValue getMax() {
if ((values.size() > 0)) {
return values.stream().max((o1, o2) -> o1.getValue().compareTo(o2.getValue())).get();
return values.stream().max(Comparator.comparing(TimeSeriesValue::getValue)).get();
}
throw new RuntimeException("Временной ряд пустой");
}
public TimeSeriesValue getMin() {
if ((values.size() > 0)) {
return values.stream().min((o1, o2) -> o1.getValue().compareTo(o2.getValue())).get();
return values.stream().min(Comparator.comparing(TimeSeriesValue::getValue)).get();
}
throw new RuntimeException("Временной ряд пустой");
}