General code cleanup 29/30229/1
authorStephen Kitt <skitt@redhat.com>
Thu, 26 Nov 2015 08:47:20 +0000 (09:47 +0100)
committerStephen Kitt <skitt@redhat.com>
Thu, 26 Nov 2015 08:47:20 +0000 (09:47 +0100)
Use <> where appropriate.

Remove a couple of unnecessary unboxing statements.

Reduce variable scope.

Simplify a couple of boolean expressions (Optional<T>.get() is
instanceof T if it's not null).

Fix up some documentation.

Change-Id: I6db39ad20e3245c03fff94cb96fbc8b09f4f57dc
Signed-off-by: Stephen Kitt <skitt@redhat.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java
openstack/net-virt-it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/it/NetvirtIT.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/SfcClassifierService.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java

index a06f8cf91413a1ff6d461ce04e0b6f2925e956d5..4d6f0f0622fd0ded895ebceb6dce2cfd4568cb35 100644 (file)
@@ -61,17 +61,14 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 
 public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoCloseable{
-    private Map<ConnectionInfo, HwvtepConnectionInstance> clients =
-                    new ConcurrentHashMap<ConnectionInfo,HwvtepConnectionInstance>();
+    private Map<ConnectionInfo, HwvtepConnectionInstance> clients = new ConcurrentHashMap<>();
     private static final Logger LOG = LoggerFactory.getLogger(HwvtepConnectionManager.class);
     private static final String ENTITY_TYPE = "hwvtep";
 
     private DataBroker db;
     private TransactionInvoker txInvoker;
-    private Map<ConnectionInfo,InstanceIdentifier<Node>> instanceIdentifiers =
-                    new ConcurrentHashMap<ConnectionInfo,InstanceIdentifier<Node>>();
-    private Map<Entity, HwvtepConnectionInstance> entityConnectionMap =
-                    new ConcurrentHashMap<>();
+    private Map<ConnectionInfo,InstanceIdentifier<Node>> instanceIdentifiers = new ConcurrentHashMap<>();
+    private Map<Entity, HwvtepConnectionInstance> entityConnectionMap = new ConcurrentHashMap<>();
     private EntityOwnershipService entityOwnershipService;
     private HwvtepDeviceEntityOwnershipListener hwvtepDeviceEntityOwnershipListener;
 
@@ -303,18 +300,17 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         if (dbSchema != null) {
             GenericTableSchema hwvtepSchema = TyperUtils.getTableSchema(dbSchema, Global.class);
 
-            List<String> hwvtepTableColumn = new ArrayList<String>();
+            List<String> hwvtepTableColumn = new ArrayList<>();
             hwvtepTableColumn.addAll(hwvtepSchema.getColumns());
             Select<GenericTableSchema> selectOperation = op.select(hwvtepSchema);
-            selectOperation.setColumns(hwvtepTableColumn);;
+            selectOperation.setColumns(hwvtepTableColumn);
 
-            ArrayList<Operation> operations = new ArrayList<Operation>();
+            ArrayList<Operation> operations = new ArrayList<>();
             operations.add(selectOperation);
             operations.add(op.comment("Fetching hardware_vtep table rows"));
 
-            List<OperationResult> results = null;
             try {
-                results = connectionInstance.transact(dbSchema, operations).get();
+                List<OperationResult> results = connectionInstance.transact(dbSchema, operations).get();
                 if (results != null ) {
                     OperationResult selectResult = results.get(0);
                     globalRow = TyperUtils.getTypedRowWrapper(
@@ -330,7 +326,6 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
     }
 
     private Entity getEntityFromConnectionInstance(@Nonnull HwvtepConnectionInstance hwvtepConnectionInstance) {
-        YangInstanceIdentifier entityId = null;
         InstanceIdentifier<Node> iid = hwvtepConnectionInstance.getInstanceIdentifier();
         if ( iid == null ) {
             //TODO: Is Global the right one?
@@ -342,7 +337,8 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
                     + "connection {}",iid, hwvtepConnectionInstance.getConnectionInfo());
 
         }
-        entityId = HwvtepSouthboundUtil.getInstanceIdentifierCodec().getYangInstanceIdentifier(iid);
+        YangInstanceIdentifier entityId =
+                HwvtepSouthboundUtil.getInstanceIdentifierCodec().getYangInstanceIdentifier(iid);
         Entity deviceEntity = new Entity(ENTITY_TYPE, entityId);
         LOG.debug("Entity {} created for device connection {}",
                 deviceEntity, hwvtepConnectionInstance.getConnectionInfo());
index 71fe6e47aceac28965a1534fbe7896268add902e..cdc846e53d93977e80cf12b42f6430514cada88f 100644 (file)
@@ -296,7 +296,7 @@ public class NetvirtIT extends AbstractMdsalTestBase {
 
     /**
      * Test passive connection mode. The southbound starts in a listening mode waiting for connections on port
-     * 6640. This test will wait for incoming connections for {@link NetvirtITConstants.CONNECTION_INIT_TIMEOUT} ms.
+     * 6640. This test will wait for incoming connections for {@link NetvirtITConstants#CONNECTION_INIT_TIMEOUT} ms.
      *
      * @throws InterruptedException
      */
@@ -673,8 +673,8 @@ public class NetvirtIT extends AbstractMdsalTestBase {
      * Extract the <code>store</code> type data store contents for the particular bridge identified by
      * <code>bridgeName</code>.
      *
-     * @param connectionInfo
-     * @param bridgeName
+     * @param connectionInfo The connection information.
+     * @param bridgeName The bridge name.
      * @param store defined by the <code>LogicalDatastoreType</code> enumeration
      * @return <code>store</code> type data store contents
      */
@@ -691,8 +691,8 @@ public class NetvirtIT extends AbstractMdsalTestBase {
      * extract the <code>LogicalDataStoreType.OPERATIONAL</code> type data store contents for the particular bridge
      * identified by <code>bridgeName</code>
      *
-     * @param connectionInfo
-     * @param bridgeName
+     * @param connectionInfo The connection information.
+     * @param bridgeName The bridge name.
      * @see <code>NetvirtIT.getBridge(ConnectionInfo, String, LogicalDatastoreType)</code>
      * @return <code>LogicalDatastoreType.OPERATIONAL</code> type data store contents
      */
@@ -704,8 +704,8 @@ public class NetvirtIT extends AbstractMdsalTestBase {
      * Extract the node contents from <code>store</code> type data store for the
      * bridge identified by <code>bridgeName</code>
      *
-     * @param connectionInfo
-     * @param bridgeName
+     * @param connectionInfo The connection information.
+     * @param bridgeName The bridge name.
      * @param store defined by the <code>LogicalDatastoreType</code> enumeration
      * @return <code>store</code> type data store contents
      */
index d3357053d1e7ebf0738ba3c1753da5d14d7fa69b..182dc77aa11b89d259ffab004a858cf4735a65fb 100644 (file)
@@ -468,7 +468,7 @@ public class SfcClassifierService extends AbstractServiceInstance implements Con
         flowBuilder.setCookie(new FlowCookie(getCookie(FlowID.FLOW_SFARP)));
         flowBuilder.setCookieMask(new FlowCookie(getCookie(FlowID.FLOW_SFARP)));
 
-        if (write == true) {
+        if (write) {
             InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructions = Lists.newArrayList();
@@ -582,11 +582,11 @@ public class SfcClassifierService extends AbstractServiceInstance implements Con
                 //MatchUtils.createDstL3IPv4Match(matchBuilder, aceIpv4.getDestinationIpv4Network());
                 MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
                 MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
-                        aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
+                        aceIp.getDestinationPortRange().getLowerPort().getValue());
             } else {
                 MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
                 MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
-                        aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
+                        aceIp.getDestinationPortRange().getLowerPort().getValue());
             }
         } else if (matches.getAceType() instanceof AceEth) {
             AceEth aceEth = (AceEth) matches.getAceType();
index ecfedfe48f1b787f71331f454c1dc944ad72898e..3e6ac40ae28e66cf80e7fac82f39f44ee16eaed0 100644 (file)
@@ -268,7 +268,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
                     LogicalDatastoreType.OPERATIONAL, nodePath);
             transaction.close();
             Optional<Node> optional = nodeFuture.get();
-            if (optional != null && optional.isPresent() && optional.get() instanceof Node) {
+            if (optional != null && optional.isPresent() && optional.get() != null) {
                 return this.getConnectionInstance(optional.get());
             } else {
                 LOG.warn("Found non-topological node {} on path {}",optional);