@@ -70,26 +70,35 @@ public double get(BdewKey key) {
7070 return values .get (key );
7171 }
7272
73- /** Returns the values, that may contain the last day of the year, as a stream. */
74- public Stream <Double > lastDayOfYearValues () {
75- Stream <BdewKey > keys =
76- switch (scheme ) {
77- case BDEW1999 -> Stream .of (
78- new Bdew1999Key (WINTER , DayType .SATURDAY ),
79- new Bdew1999Key (WINTER , DayType .SUNDAY ),
80- new Bdew1999Key (WINTER , DayType .WEEKDAY ));
81- case BDEW2025 -> Stream .of (
82- new Bdew2025Key (DECEMBER , DayType .SATURDAY ),
83- new Bdew2025Key (DECEMBER , DayType .SUNDAY ),
84- new Bdew2025Key (DECEMBER , DayType .WEEKDAY ));
85- };
86-
87- return keys .map (values ::get );
88- }
73+ /**
74+ * Method to calculate the maximal value contained in this {@link BdewLoadValues}.
75+ *
76+ * @param lastDayOfYear if true, only the values, that could occur at the last day of a year, are
77+ * considered
78+ * @return the maximal value
79+ */
80+ public double getMaxValue (boolean lastDayOfYear ) {
81+ Stream <Double > stream ;
82+
83+ if (lastDayOfYear ) {
84+ Stream <BdewKey > keys =
85+ switch (scheme ) {
86+ case BDEW1999 -> Stream .of (
87+ new Bdew1999Key (WINTER , DayType .SATURDAY ),
88+ new Bdew1999Key (WINTER , DayType .SUNDAY ),
89+ new Bdew1999Key (WINTER , DayType .WEEKDAY ));
90+ case BDEW2025 -> Stream .of (
91+ new Bdew2025Key (DECEMBER , DayType .SATURDAY ),
92+ new Bdew2025Key (DECEMBER , DayType .SUNDAY ),
93+ new Bdew2025Key (DECEMBER , DayType .WEEKDAY ));
94+ };
95+
96+ stream = keys .map (values ::get );
97+ } else {
98+ stream = values .values ().stream ();
99+ }
89100
90- /** Returns the values as a stream. */
91- public Stream <Double > values () {
92- return values .values ().stream ();
101+ return stream .max (Comparator .naturalOrder ()).orElse (0.0 );
93102 }
94103
95104 @ Override
0 commit comments