-
Notifications
You must be signed in to change notification settings - Fork 13
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
Intern cell explicit positionning #292
Conversation
77aac53
to
ffff4f1
Compare
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
7b1dcbe
to
e3d9c38
Compare
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
...m-core/src/main/java/com/powsybl/sld/layout/positionfromextension/PositionFromExtension.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
single-line-diagram-core/src/main/java/com/powsybl/sld/layout/BlockPositionner.java
Outdated
Show resolved
Hide resolved
single-line-diagram-core/src/main/java/com/powsybl/sld/layout/BlockPositionner.java
Outdated
Show resolved
Hide resolved
@@ -58,6 +59,12 @@ | |||
|
|||
private String label; | |||
|
|||
private Optional<Integer> order = Optional.empty(); |
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.
Optional should not be used as parameter of a class or a method, but rather only in return values.
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.
Just some more arguments, as I didn't manage to convince you; intellij linter makes it a warning which says
Optional was designed to provide a limited mechanism for library method return types in which a clear way to represent "no result" was needed. Using a field with the java.util.Optional type is also problematic if the class needs to be Serializable, as java.util.Optional is not serializable.
See also the POJOs paragraph in http://dolszewski.com/java/java-8-optional-use-cases/
single-line-diagram-core/src/test/java/com/powsybl/sld/raw/TestLanesWithUnileg.java
Outdated
Show resolved
Hide resolved
single-line-diagram-core/src/test/resources/InternalBranchesBusBreakerH.json
Outdated
Show resolved
Hide resolved
single-line-diagram-core/src/main/java/com/powsybl/sld/model/AbstractBusCell.java
Outdated
Show resolved
Hide resolved
0bf0b94
to
e3d9c38
Compare
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
bcaccbe
to
19c2a90
Compare
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
19c2a90
to
494d229
Compare
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
graph.getNodes().stream().filter(node -> node.getDirection() != Direction.UNDEFINED).forEach(node -> { | ||
BusCell cell = (BusCell) node.getCell(); | ||
cell.setDirection(node.getDirection()); | ||
cell.setOrder(node.getOrder().orElse(null)); |
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.
Here we remove the order if node.getOrder().isEmpty()
. I think that's dangerous, if one node of the cell has no order it might remove it. I'd rather write node.getOrder().ifPresent(cell::setOrder)
@Override | ||
protected void writeJsonContent(JsonGenerator generator) throws IOException { | ||
super.writeJsonContent(generator); | ||
generator.writeStringField("feederType", feederType.name()); | ||
generator.writeNumberField("order", order); | ||
generator.writeNumberField("order", getOrder().orElse(-1)); |
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.
We should avoid writing -1 as it's the same as no information. I'll replace this line with getOrder().ifPresent(order -> generator.writeNumberField("order", order))
@@ -58,6 +59,12 @@ | |||
|
|||
private String label; | |||
|
|||
private Optional<Integer> order = Optional.empty(); |
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.
Just some more arguments, as I didn't manage to convince you; intellij linter makes it a warning which says
Optional was designed to provide a limited mechanism for library method return types in which a clear way to represent "no result" was needed. Using a field with the java.util.Optional type is also problematic if the class needs to be Serializable, as java.util.Optional is not serializable.
See also the POJOs paragraph in http://dolszewski.com/java/java-8-optional-use-cases/
} | ||
|
||
@Override | ||
public void setOrder(Integer order) { |
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.
I don't think we need to use Integer
instead of int
, as we never remove the order. If so one day, it should be done more explicitly via a removeOrder
. I'll add such a method just in case
@@ -40,6 +40,12 @@ public Orientation toOrientation() { | |||
|
|||
int newHPosition(int hPosition); | |||
|
|||
Optional<Integer> getOrder(); | |||
|
|||
void setOrder(Integer order); |
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.
As said above, I'll replace Integer
with int
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Kudos, SonarCloud Quality Gate passed! |
Please check if the PR fulfills these requirements (please use
'[x]'
to check the checkboxes, or submit the PR and then click the checkboxes)Does this PR already have an issue describing the problem ? If so, link to this issue using
'#XXX'
and skip the restWhat kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
feature
What is the current behavior? (You can also link to an open issue here)
Only ExternCells have an order.
What is the new behavior (if this is a feature change)?
Introduce ability to define an order, and explicit orientation to a vertical InternCell.
No Extension is available in iidm to support that. See TestInternCellExplicitPosition.java
Does this PR introduce a breaking change or deprecate an API? If yes, check the following:
Other information:
(if any of the questions/checkboxes don't apply, please delete them entirely)