Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / netconf-console / src / main / java / org / opendaylight / netconf / console / utils / NetconfConsoleUtils.java
index 1ce147a5c7f0e8716606c6c5a80e7d229f059b1a..560ddcae4a02923fb683b24e7f03d2115467191a 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfConsoleUtils {
+public final class NetconfConsoleUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfConsoleUtils.class);
 
@@ -32,7 +32,7 @@ public class NetconfConsoleUtils {
     }
 
     /**
-     * Returns a list of NETCONF nodes for the IP
+     * Returns a list of NETCONF nodes for the IP.
      * @param deviceIp :IP address of NETCONF device
      * @param db :An instance of the {@link DataBroker}
      * @return :list on NETCONF nodes
@@ -67,40 +67,39 @@ public class NetconfConsoleUtils {
     }
 
     /**
-     * Returns a list with one NETCONF node for the IP and Port
+     * Returns a list with one NETCONF node for the IP and Port.
      * @param deviceIp :IP address of NETCONF device
      * @param devicePort :Port of NETCONF device
      * @param db :An instance of the {@link DataBroker}
      * @return :NETCONF node instance
      */
-    public static Node getNetconfNodeFromIpAndPort(final String deviceIp, final String devicePort, final DataBroker db) {
+    public static Node getNetconfNodeFromIpAndPort(final String deviceIp, final String devicePort,
+                                                   final DataBroker db) {
         final Topology topology = read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.NETCONF_TOPOLOGY_IID, db);
         if (isNetconfNodesPresent(topology)) {
             for (Node node : topology.getNode()) {
                 final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
                 if (netconfNode != null
                         && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)
-                        && devicePort.equals(netconfNode.getPort().getValue().toString()))
+                        && devicePort.equals(netconfNode.getPort().getValue().toString())) {
                     return node;
+                }
             }
         }
         return null;
     }
 
     /**
-     * Checks if the NETCONF topology contains nodes
+     * Checks if the NETCONF topology contains nodes.
      * @param topology :NETCONF topology instance
      * @return :<code>true</code> if not empty, else, <code>false</code>
      */
     private static boolean isNetconfNodesPresent(final Topology topology) {
-        if (topology == null || topology.getNode() == null || topology.getNode().isEmpty()) {
-            return false;
-        }
-        return true;
+        return topology != null && topology.getNode() != null && !topology.getNode().isEmpty();
     }
 
     /**
-     * Wait for datastore to populate NETCONF data
+     * Wait for datastore to populate NETCONF data.
      * @param deviceIp :IP address of NETCONF device
      */
     public static void waitForUpdate(final String deviceIp) {
@@ -112,14 +111,14 @@ public class NetconfConsoleUtils {
     }
 
     /**
-     * Blocking read transaction
+     * Blocking read transaction.
      * @param store :DatastoreType
      * @param path :InstanceIdentifier
      * @param db :An instance of the {@link DataBroker}
      * @return :data read from path
      */
-    public static <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(final LogicalDatastoreType store,
-            final InstanceIdentifier<D> path, final DataBroker db) {
+    public static <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(
+            final LogicalDatastoreType store, final InstanceIdentifier<D> path, final DataBroker db) {
         D result = null;
         final ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
         Optional<D> optionalData;