replace inventory Preconditions by requireNonNull 02/91102/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Tue, 5 May 2020 13:48:11 +0000 (15:48 +0200)
committerGilles Thouenon <gilles.thouenon@orange.com>
Fri, 10 Jul 2020 12:42:08 +0000 (14:42 +0200)
as advised by SpotBugs

JIRA: TRNSPRTPCE-207 TRNSPRTPCE-241 TRNSPRTPCE-265
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I2c2875d6ef1ab319a6f38f48bdc6f683ac9a4149

inventory/src/main/java/org/opendaylight/transportpce/inventory/INode121.java
inventory/src/main/java/org/opendaylight/transportpce/inventory/INode221.java

index 5ba9a938f3500a9b666433418fa5ac05b7deca6b..9d7aa642334dfeb43684d417363265b8353fca84 100644 (file)
@@ -8,11 +8,11 @@
 
 package org.opendaylight.transportpce.inventory;
 
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurrentTimestamp;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
 
-import com.google.common.base.Preconditions;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -184,8 +184,7 @@ public class INode121 {
                 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
 
         LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
-        try (Connection connection = dataSource.getConnection()) {
-            Preconditions.checkNotNull(connection);
+        try (Connection connection = requireNonNull(dataSource.getConnection())) {
             for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
                 Shelves shelve = deviceObject.get().getShelves().get(i);
                 String shelfName = shelve.getShelfName();
@@ -216,8 +215,7 @@ public class INode121 {
         }
         LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
 
-        try (Connection connection = dataSource.getConnection()) {
-            Preconditions.checkNotNull(connection);
+        try (Connection connection = requireNonNull(dataSource.getConnection())) {
             for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
                 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
 
index e394860a1b9cbf4cf99fadf5d01479e6c5ac6d0c..e22cbd404fc129259e1f82309c70393c3720abef 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.transportpce.inventory;
 
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurrentTimestamp;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
 
-import com.google.common.base.Preconditions;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -184,8 +184,7 @@ public class INode221 {
                 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
 
         LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
-        try (Connection connection = dataSource.getConnection()) {
-            Preconditions.checkNotNull(connection);
+        try (Connection connection = requireNonNull(dataSource.getConnection())) {
             for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
                 Shelves shelve = deviceObject.get().getShelves().get(i);
                 String shelfName = shelve.getShelfName();
@@ -217,8 +216,7 @@ public class INode221 {
         }
         LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
 
-        try (Connection connection = dataSource.getConnection()) {
-            Preconditions.checkNotNull(connection);
+        try (Connection connection = requireNonNull(dataSource.getConnection())) {
             for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
                 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);