Skip to content

Commit 7eb0ca7

Browse files
committed
Including reviewer's comments.
1 parent 48a4ec8 commit 7eb0ca7

File tree

5 files changed

+12
-41
lines changed

5 files changed

+12
-41
lines changed

src/main/java/edu/ie3/datamodel/io/naming/timeseries/LoadProfileMetaInformation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public boolean equals(Object o) {
3232

3333
@Override
3434
public int hashCode() {
35-
return Objects.hash(profile);
35+
return Objects.hash(super.hashCode(), profile);
3636
}
3737

3838
@Override

src/main/java/edu/ie3/datamodel/io/source/PowerValueSource.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,21 @@
1717

1818
/** Interface defining base functionality for power value sources. */
1919
public sealed interface PowerValueSource<
20-
P extends PowerProfile, ID extends PowerValueSource.InputData>
20+
P extends PowerProfile, I extends PowerValueSource.PowerValueIdentifier>
2121
permits PowerValueSource.MarkovBased, PowerValueSource.TimeSeriesBased {
2222

2323
/** Returns the profile of this source. */
2424
P getProfile();
2525

26-
/**
27-
* Method to get the next power value based on the provided input data.
28-
*
29-
* @param data input data that is used to calculate the next power value.
30-
* @return an option for the power value.
31-
*/
32-
Optional<PValue> getValue(ID data);
33-
3426
/**
3527
* Method to get a supplier for the next power value based on the provided input data. Depending
3628
* on the implementation the supplier will either always return the same value or each time a
37-
* random value. To return one constant value please use {@link #getValue(InputData)}.
29+
* random value.
3830
*
3931
* @param data input data that is used to calculate the next power value.
4032
* @return A supplier for an option on the value at the given time step.
4133
*/
42-
Supplier<Optional<PValue>> getValueSupplier(ID data);
34+
Supplier<Optional<PValue>> getValueSupplier(I data);
4335

4436
/**
4537
* Method to determine the next timestamp for which data is present.
@@ -63,16 +55,16 @@ non-sealed interface TimeSeriesBased
6355
extends PowerValueSource<LoadProfile, TimeSeriesInputValue> {}
6456

6557
/** Interface for markov-chain-based power value sources. */
66-
non-sealed interface MarkovBased extends PowerValueSource<PowerProfile, InputData> {}
58+
non-sealed interface MarkovBased extends PowerValueSource<PowerProfile, PowerValueIdentifier> {}
6759

6860
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6961
// input data
7062

7163
/**
72-
* Interface for the input data of {@link #getValue(InputData)}. The data is used to determine the
73-
* next power.
64+
* Interface for the input data of {@link #getValueSupplier(PowerValueIdentifier)}. The data is
65+
* used to determine the next power.
7466
*/
75-
sealed interface InputData permits PowerValueSource.TimeSeriesInputValue {
67+
sealed interface PowerValueIdentifier permits PowerValueSource.TimeSeriesInputValue {
7668
/** Returns the timestamp for which a power value is needed. */
7769
ZonedDateTime getTime();
7870
}
@@ -82,7 +74,7 @@ sealed interface InputData permits PowerValueSource.TimeSeriesInputValue {
8274
*
8375
* @param time
8476
*/
85-
record TimeSeriesInputValue(ZonedDateTime time) implements InputData {
77+
record TimeSeriesInputValue(ZonedDateTime time) implements PowerValueIdentifier {
8678
@Override
8779
public ZonedDateTime getTime() {
8880
return time;

src/main/java/edu/ie3/datamodel/io/source/csv/CsvLoadProfileSource.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,11 @@ public Set<LoadProfileEntry<V>> getEntries() {
7070
return loadProfileTimeSeries.getEntries();
7171
}
7272

73-
@Override
74-
public Optional<PValue> getValue(TimeSeriesInputValue data) {
75-
return loadProfileTimeSeries.getValue(data.time());
76-
}
77-
7873
@Override
7974
public Supplier<Optional<PValue>> getValueSupplier(TimeSeriesInputValue data) {
8075
return loadProfileTimeSeries.supplyValue(data.time());
8176
}
8277

83-
@Override
84-
public P getProfile() {
85-
return loadProfileTimeSeries.getLoadProfile();
86-
}
87-
8878
@Override
8979
public Optional<ComparableQuantity<Power>> getMaxPower() {
9080
return loadProfileTimeSeries.maxPower();

src/main/java/edu/ie3/datamodel/io/source/sql/SqlLoadProfileSource.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,11 @@ public Set<LoadProfileEntry<V>> getEntries() {
9999
return getEntries(queryFull, ps -> {});
100100
}
101101

102-
@Override
103-
public Optional<PValue> getValue(TimeSeriesInputValue data) {
104-
ZonedDateTime time = data.time();
105-
return queryForValue(time).map(loadValue -> loadValue.getValue(time, profile));
106-
}
107-
108102
@Override
109103
public Supplier<Optional<PValue>> getValueSupplier(TimeSeriesInputValue data) {
110104
ZonedDateTime time = data.time();
111105
Optional<LoadValues<P>> loadValueOption = queryForValue(time);
112-
113-
if (loadValueOption.isPresent()) {
114-
LoadValues<P> loadValue = loadValueOption.get();
115-
return () -> Optional.of(loadValue.getValue(time, profile));
116-
} else {
117-
return Optional::empty;
118-
}
106+
return () -> loadValueOption.map(v -> v.getValue(time, profile));
119107
}
120108

121109
@Override

src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlLoadProfileSourceIT.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class SqlLoadProfileSourceIT extends Specification implements TestContainerHelpe
6363

6464
def "A SqlTimeSeriesSource can read and correctly parse a single value for a specific date"() {
6565
when:
66-
def value = loadSource.getValue(new PowerValueSource.TimeSeriesInputValue(TIME_00MIN))
66+
def supplier = loadSource.getValueSupplier(new PowerValueSource.TimeSeriesInputValue(TIME_00MIN))
67+
def value = supplier.get()
6768

6869
then:
6970
value.present

0 commit comments

Comments
 (0)