Skip to content

Conversation

staudtMarius
Copy link
Member

@staudtMarius staudtMarius commented Sep 17, 2025

Resolves #1438

Merge #1450 first.

@staudtMarius staudtMarius self-assigned this Sep 17, 2025
@staudtMarius staudtMarius added enhancement New feature or request code quality Code readability or structure is improved labels Sep 17, 2025
staudtMarius and others added 3 commits September 23, 2025 08:17
# Conflicts:
#	src/main/java/edu/ie3/datamodel/io/factory/timeseries/LoadProfileFactory.java
#	src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java
#	src/main/java/edu/ie3/datamodel/io/source/csv/CsvLoadProfileSource.java
#	src/main/java/edu/ie3/datamodel/io/source/sql/SqlLoadProfileSource.java
#	src/main/java/edu/ie3/datamodel/models/timeseries/repetitive/LoadProfileTimeSeries.java
#	src/main/java/edu/ie3/datamodel/models/timeseries/repetitive/RandomLoadProfileTimeSeries.java
#	src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlLoadProfileSourceIT.groovy
Copy link
Member

@sebastian-peter sebastian-peter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and questions from my side

* Interface for the input data of {@link #getValue(InputData)}. The data is used to determine the
* next power.
*/
sealed interface InputData permits PowerValueSource.TimeSeriesInputValue {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can think about a different name for the interface here. InputData seems quite generic. Spontaneously I'd think of something that includes Identifier, maybe PowerValueIdentifier, or something better?


/** Interface defining base functionality for power value sources. */
public sealed interface PowerValueSource<
P extends PowerProfile, ID extends PowerValueSource.InputData>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check out the sonarqube issue

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), profile);
return Objects.hash(profile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't do this, especially because the equals method still relies on the super class

Comment on lines +26 to +32
/**
* Method to get the next power value based on the provided input data.
*
* @param data input data that is used to calculate the next power value.
* @return an option for the power value.
*/
Optional<PValue> getValue(ID data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method now becomes obsolete with the addition of getValueSupplier. We can just use a supplier all the time, even if it always returns the same value.

Comment on lines +83 to 86
@Override
public P getProfile() {
return loadProfileTimeSeries.getLoadProfile();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary ovveride imho

Comment on lines +113 to +118
if (loadValueOption.isPresent()) {
LoadValues<P> loadValue = loadValueOption.get();
return () -> Optional.of(loadValue.getValue(time, profile));
} else {
return Optional::empty;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can use the map function on the optional here?

Comment on lines -82 to -88
/**
* Get all {@link ZonedDateTime}s after the given time.
*
* @param time given time
* @return a list of all time keys
*/
public abstract List<ZonedDateTime> getTimeKeysAfter(ZonedDateTime time);
Copy link
Member

@sebastian-peter sebastian-peter Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, finally 👍

Copy link
Member Author

@staudtMarius staudtMarius Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with finally? I think we added this method not long ago. I just moved this method to another place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought we would get rid of this method...

Comment on lines +69 to 77
/**
* Get all {@link ZonedDateTime}s after the given time.
*
* @param time given time
* @return a list of all time keys
*/
public List<ZonedDateTime> getTimeKeysAfter(ZonedDateTime time) {
return timeToValue.keySet().stream().filter(timeKey -> timeKey.isAfter(time)).sorted().toList();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should me mark this method as obsolete, or just remove it completely? Or are there reasons to keep it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we are using this method in SIMONA. But I will check this later and remove it, if we don't use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be replaced by getNextDateTime in SIMONA I think. But we don't have to delete this method right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Code readability or structure is improved enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abstracting power value sources
3 participants