Skip to content

Commit e1948ad

Browse files
authored
Merge pull request #509 from ie3-institute/to/#508-fix-code-smells
To/#508 fix code smells
2 parents 330e28f + 68cc7ab commit e1948ad

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/main/java/edu/ie3/datamodel/graph/ImpedanceWeightedGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void setEdgeWeightQuantity(
5252
* ComparableQuantity)} instead, as it provides means for proper unit handling
5353
*/
5454
@Override
55-
@Deprecated
55+
@Deprecated(since = ("Deprecated since 2.1.0. See Javadocs for more information."))
5656
public void setEdgeWeight(ImpedanceWeightedEdge edge, double impedanceInOhm) {
5757
super.setEdgeWeight(edge, impedanceInOhm);
5858
}

src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,24 @@ private static void addImpedanceGraphEdge(
222222
NodeInput nodeA = connectorInput.getNodeA();
223223
NodeInput nodeB = connectorInput.getNodeB();
224224
/* Add an edge if it is not a switch or the switch is closed */
225-
if (!(connectorInput instanceof SwitchInput) || ((SwitchInput) connectorInput).isClosed())
225+
if (!(connectorInput instanceof SwitchInput sw) || ((SwitchInput) connectorInput).isClosed())
226226
graph.addEdge(nodeA, nodeB);
227227

228-
if (connectorInput instanceof LineInput) {
229-
LineInput line = (LineInput) connectorInput;
228+
if (connectorInput instanceof LineInput line) {
230229
graph.setEdgeWeightQuantity(
231230
graph.getEdge(nodeA, nodeB),
232231
calcImpedance(line.getType().getR(), line.getType().getX(), line.getLength()));
233232
}
234-
if (connectorInput instanceof SwitchInput) {
235-
SwitchInput sw = (SwitchInput) connectorInput;
233+
if (connectorInput instanceof SwitchInput sw && sw.isClosed()) {
236234
// assumption: closed switch has a resistance of 1 OHM
237-
if (sw.isClosed())
238-
graph.setEdgeWeightQuantity(graph.getEdge(nodeA, nodeB), Quantities.getQuantity(1d, OHM));
235+
graph.setEdgeWeightQuantity(graph.getEdge(nodeA, nodeB), Quantities.getQuantity(1d, OHM));
239236
}
240-
if (connectorInput instanceof Transformer2WInput) {
241-
Transformer2WInput trafo2w = (Transformer2WInput) connectorInput;
237+
if (connectorInput instanceof Transformer2WInput trafo2w) {
242238
graph.setEdgeWeightQuantity(
243239
graph.getEdge(nodeA, nodeB),
244240
calcImpedance(trafo2w.getType().getrSc(), trafo2w.getType().getxSc()));
245241
}
246-
if (connectorInput instanceof Transformer3WInput) {
247-
Transformer3WInput trafo3w = (Transformer3WInput) connectorInput;
242+
if (connectorInput instanceof Transformer3WInput trafo3w) {
248243
graph.addEdge(nodeA, trafo3w.getNodeC());
249244

250245
graph.setEdgeWeightQuantity(

0 commit comments

Comments
 (0)