Fix spotbugs issues of the PCE module
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / PcePathDescription.java
index bb29feb6d4f49f9b474aa18c492af47f74f49943..ff38b749685fe29d7721622b403a41b03a7b2f4b 100644 (file)
@@ -8,9 +8,11 @@
 package org.opendaylight.transportpce.pce;
 
 import com.google.common.collect.ImmutableList;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
@@ -37,16 +39,10 @@ public class PcePathDescription {
     private static final Logger LOG = LoggerFactory.getLogger(PcePathDescription.class);
 
     private List<PceLink> pathAtoZ = null;
+    private List<PceLink> pathZtoA = null;
     private PceResult rc;
-
-    public PceResult getReturnStructure() {
-        return rc;
-    }
-
     private Map<LinkId, PceLink> allPceLinks = null;
 
-    private List<PceLink> pathZtoA = null;
-
     public PcePathDescription(List<PceLink> pathAtoZ, Map<LinkId, PceLink> allPceLinks, PceResult rc) {
         super();
         this.allPceLinks = allPceLinks;
@@ -55,8 +51,8 @@ public class PcePathDescription {
     }
 
     public PceResult buildDescriptions() {
-        LOG.info("In buildDescriptions: AtoZ =  {}", pathAtoZ.toString());
-        List<AToZ> atozList = new ArrayList<AToZ>();
+        LOG.info("In buildDescriptions: AtoZ =  {}", pathAtoZ);
+        List<AToZ> atozList = new ArrayList<>();
         if (pathAtoZ == null) {
             rc.setRC(ResponseCodes.RESPONSE_FAILED);
             LOG.error("In buildDescriptions: there is empty AtoZ path");
@@ -75,9 +71,9 @@ public class PcePathDescription {
         }
         rc.setAtoZDirection(atoZDirectionBldr.build());
         pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse();
-        LOG.info("In buildDescriptions: ZtoA {}", pathZtoA.toString());
+        LOG.info("In buildDescriptions: ZtoA {}", pathZtoA);
 
-        List<ZToA> ztoaList = new ArrayList<ZToA>();
+        List<ZToA> ztoaList = new ArrayList<>();
         if (pathZtoA == null) {
             rc.setRC(ResponseCodes.RESPONSE_FAILED);
             LOG.error("In buildDescriptions: there is empty ZtoA path");
@@ -114,7 +110,7 @@ public class PcePathDescription {
         Resource clientResource = new ResourceBuilder().setResource(stp).build();
         AToZ firstResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
         etoeList.add(firstResource);
-        index++;
+        index += 1;
         for (PceLink pcelink : path) {
             String srcName = pcelink.getSourceId().getValue();
             // Nodes
@@ -127,7 +123,7 @@ public class PcePathDescription {
             AToZKey sourceKey = new AToZKey(index.toString());
             Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
             AToZ srcResource = new AToZBuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build();
-            index++;
+            index += 1;
             etoeList.add(srcResource);
 
             // source TP
@@ -140,7 +136,7 @@ public class PcePathDescription {
             AToZKey srcTPKey = new AToZKey(index.toString());
             Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
             AToZ stpResource = new AToZBuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
-            index++;
+            index += 1;
             etoeList.add(stpResource);
 
             String linkName = pcelink.getLinkId().getValue();
@@ -154,7 +150,7 @@ public class PcePathDescription {
             AToZKey linkKey = new AToZKey(index.toString());
             Resource nodeResource2 = new ResourceBuilder().setResource(atozLink).build();
             AToZ linkResource = new AToZBuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build();
-            index++;
+            index += 1;
             etoeList.add(linkResource);
 
             String destName = pcelink.getDestId().getValue();
@@ -168,7 +164,7 @@ public class PcePathDescription {
             AToZKey destTPKey = new AToZKey(index.toString());
             Resource tpResource2 = new ResourceBuilder().setResource(dtp).build();
             AToZ ttpResource = new AToZBuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
-            index++;
+            index += 1;
             etoeList.add(ttpResource);
 
             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
@@ -193,8 +189,7 @@ public class PcePathDescription {
                 .setTpNodeId(xname).setTpId(tpName)
                 .build();
 
-
-        index++;
+        index += 1;
         clientKey = new AToZKey(index.toString());
         clientResource = new ResourceBuilder().setResource(stp).build();
         lastResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
@@ -219,12 +214,12 @@ public class PcePathDescription {
         Resource clientResource = new ResourceBuilder().setResource(stp).build();
         ZToA firstResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
         etoelist.add(firstResource);
-        index++;
+        index += 1;
 
         for (PceLink pcelinkAtoZ : path) {
 
             pcelink = this.allPceLinks.get(pcelinkAtoZ.getOppositeLink());
-            LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ.toString(), pcelink.toString());
+            LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ, pcelink);
 
             String srcName = pcelink.getSourceId().getValue();
 
@@ -239,7 +234,7 @@ public class PcePathDescription {
             ZToAKey sourceKey = new ZToAKey(index.toString());
             Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
             ZToA srcResource = new ZToABuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build();
-            index++;
+            index += 1;
             etoelist.add(srcResource);
 
             // source TP
@@ -252,7 +247,7 @@ public class PcePathDescription {
             ZToAKey srcTPKey = new ZToAKey(index.toString());
             Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
             ZToA stpResource = new ZToABuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
-            index++;
+            index += 1;
             etoelist.add(stpResource);
 
             String linkName = pcelink.getLinkId().getValue();
@@ -265,7 +260,7 @@ public class PcePathDescription {
             ZToAKey linkKey = new ZToAKey(index.toString());
             Resource nodeResource2 = new ResourceBuilder().setResource(ztoaLink).build();
             ZToA linkResource = new ZToABuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build();
-            index++;
+            index += 1;
             etoelist.add(linkResource);
 
             String destName = pcelink.getDestId().getValue();
@@ -278,7 +273,7 @@ public class PcePathDescription {
             ZToAKey destTPKey = new ZToAKey(index.toString());
             Resource tpResource2 = new ResourceBuilder().setResource(ttp).build();
             ZToA ttpResource = new ZToABuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
-            index++;
+            index += 1;
             etoelist.add(ttpResource);
 
 
@@ -300,13 +295,14 @@ public class PcePathDescription {
         stp = new TerminationPointBuilder()
                 .setTpNodeId(xname).setTpId(tpName).build();
 
-
-        index++;
+        index += 1;
         clientKey = new ZToAKey(index.toString());
         clientResource = new ResourceBuilder().setResource(stp).build();
         lastResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
         etoelist.add(lastResource);
-
     }
 
+    public PceResult getReturnStructure() {
+        return rc;
+    }
 }