-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider sides when applying limitReductions with IdentifiableCriterion #3050
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
72f51dc
Consider sides when applying limitReductions with IdentifiableCriterion
olperr1 4a94fab
Add unit test
olperr1 387db64
Code review
olperr1 ae800ed
Code review
olperr1 f4aedba
Merge branch 'main' into criteria_apply_with_side
annetill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,7 +17,9 @@ | |||||||||||||
import java.util.Objects; | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* <p>Criterion checking that at least one side of a network element belongs to a country defined in a list.</p> | ||||||||||||||
* <p>Criterion checking that one of side of the network element belongs to a country defined in a list.</p> | ||||||||||||||
* <p>When <code>filter</code> is called with a non-null <code>side</code>, only the country on this particular side | ||||||||||||||
* is checked. Else, the validation is performed on whichever side.</p> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "on whichever side" does not reflect what's written in the code.
Suggested change
|
||||||||||||||
* @author Olivier Perrin {@literal <olivier.perrin@rte-france.com>} | ||||||||||||||
*/ | ||||||||||||||
public class AtLeastOneCountryCriterion implements Criterion { | ||||||||||||||
|
@@ -40,7 +42,12 @@ public boolean filter(Identifiable<?> identifiable, IdentifiableType type) { | |||||||||||||
|
||||||||||||||
@Override | ||||||||||||||
public boolean filter(NetworkElement networkElement) { | ||||||||||||||
return filterWithCountries(getCountriesToCheck(networkElement)); | ||||||||||||||
return filter(networkElement, null); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@Override | ||||||||||||||
public boolean filter(NetworkElement networkElement, ThreeSides side) { | ||||||||||||||
return filterWithCountries(getCountriesToCheck(networkElement, side)); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
public List<Country> getCountries() { | ||||||||||||||
|
@@ -55,8 +62,10 @@ private List<Country> getCountriesToCheck(Identifiable<?> identifiable, Identifi | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private List<Country> getCountriesToCheck(NetworkElement networkElement) { | ||||||||||||||
return Arrays.asList(networkElement.getCountry1().orElse(null), networkElement.getCountry2().orElse(null)); | ||||||||||||||
private List<Country> getCountriesToCheck(NetworkElement networkElement, ThreeSides side) { | ||||||||||||||
return side != null ? | ||||||||||||||
Collections.singletonList(networkElement.getCountry(side).orElse(null)) : | ||||||||||||||
Arrays.asList(networkElement.getCountry1().orElse(null), networkElement.getCountry2().orElse(null)); | ||||||||||||||
flo-dup marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private boolean filterWithCountries(List<Country> countriesToCheck) { | ||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AtLeast name is a bit unexpected now that there is this sides consideration.