edit min and max

This commit is contained in:
Антон Скалкин 2023-04-03 22:47:12 +04:00
parent fae21d0f87
commit a81149bf01

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
public class TimeSeries { public class TimeSeries {
@ -90,14 +91,14 @@ public class TimeSeries {
public TimeSeriesValue getMax() { public TimeSeriesValue getMax() {
if ((values.size() > 0)) { 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("Временной ряд пустой"); throw new RuntimeException("Временной ряд пустой");
} }
public TimeSeriesValue getMin() { public TimeSeriesValue getMin() {
if ((values.size() > 0)) { 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("Временной ряд пустой"); throw new RuntimeException("Временной ряд пустой");
} }