From 682370f3da3f8391f63fcfa11f8d81aff1667042 Mon Sep 17 00:00:00 2001 From: sam <318597anton> Date: Mon, 3 Apr 2023 22:47:12 +0400 Subject: [PATCH] edit min and max --- src/main/java/ru/ulstu/datamodel/ts/TimeSeries.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/datamodel/ts/TimeSeries.java b/src/main/java/ru/ulstu/datamodel/ts/TimeSeries.java index dfa8373..3bc3146 100644 --- a/src/main/java/ru/ulstu/datamodel/ts/TimeSeries.java +++ b/src/main/java/ru/ulstu/datamodel/ts/TimeSeries.java @@ -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("Временной ряд пустой"); }