@@ -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