Clean up ShortestPathFirst 38/111538/1 master
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 25 Apr 2024 23:15:14 +0000 (01:15 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 26 Apr 2024 01:46:45 +0000 (03:46 +0200)
Fix checkstyle by moving variables around.

Change-Id: I414165c9befaf1aeaa417b0ec6986b9bc39fb901
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3c8092cb075db75d31e6b44247ac68cba7f7d0c0)

algo/algo-impl/src/main/java/org/opendaylight/algo/impl/ShortestPathFirst.java

index 0e8b3ffb0be898e75d4628782db59f55fe7e09c8..adc86936b0ba2e831c8a5949cb8d3ca778e0645b 100644 (file)
@@ -8,13 +8,11 @@
 package org.opendaylight.algo.impl;
 
 import java.util.HashMap;
-import java.util.List;
 import org.opendaylight.graph.ConnectedEdge;
 import org.opendaylight.graph.ConnectedGraph;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev220720.graph.topology.graph.VertexKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev220324.ComputationStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev220324.ConstrainedPath;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev220324.ConstrainedPathBuilder;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,15 +35,10 @@ public class ShortestPathFirst extends AbstractPathComputation {
 
     @Override
     protected ConstrainedPath computeSimplePath(final VertexKey src, final VertexKey dst) {
-        ConstrainedPathBuilder cpathBuilder;
-        List<ConnectedEdge> edges;
-        CspfPath currentPath;
-        int currentCost = Integer.MAX_VALUE;
-
         LOG.info("Start SPF Path Computation from {} to {} with constraints {}", src, dst, constraints);
 
         /* Initialize algorithm */
-        cpathBuilder = initializePathComputation(src, dst);
+        final var cpathBuilder = initializePathComputation(src, dst);
         if (cpathBuilder.getStatus() != ComputationStatus.InProgress) {
             LOG.warn("Initial configurations are not met. Abort!");
             return cpathBuilder.build();
@@ -53,11 +46,12 @@ public class ShortestPathFirst extends AbstractPathComputation {
 
         visitedVertices.clear();
 
+        int currentCost = Integer.MAX_VALUE;
         while (priorityQueue.size() != 0) {
-            currentPath = priorityQueue.poll();
+            final var currentPath = priorityQueue.poll();
             visitedVertices.put(currentPath.getVertexKey(), currentPath);
             LOG.debug("Process path to Vertex {} from Priority Queue", currentPath.getVertex());
-            edges = currentPath.getVertex().getOutputConnectedEdges();
+            final var edges = currentPath.getVertex().getOutputConnectedEdges();
 
             for (ConnectedEdge edge : edges) {
                 /* Check that Edge point to a valid Vertex and is suitable for the Constraint Address Family */