Use single-argument form of firstKeyOf() 76/26976/1
authorStephen Kitt <skitt@redhat.com>
Tue, 15 Sep 2015 09:55:29 +0000 (11:55 +0200)
committerStephen Kitt <skitt@redhat.com>
Tue, 15 Sep 2015 09:55:29 +0000 (11:55 +0200)
A few other clean-ups in the affected files:
* use plain String concatenation instead of StringBuilder where appropriate
* simplify single-use return variables
* <> operator
* avoid calling new String()

Change-Id: I3e1891509f21211c489cabb64868d78e4dddec10
Signed-off-by: Stephen Kitt <skitt@redhat.com>
openstack/net-virt-it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/it/SouthboundMapper.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/arp/ArpSender.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalHelper.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeOperationalState.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java

index bf9ac1a8ed418f0ea2c965e8f3e2849cdb2291f0..0ca89b042fca2ac984727b8f087ae409a44a9cb3 100644 (file)
@@ -82,11 +82,10 @@ public class SouthboundMapper {
     }
 
     public static InstanceIdentifier<Node> createInstanceIdentifier(NodeId nodeId) {
-        InstanceIdentifier<Node> nodePath = InstanceIdentifier
+        return InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
                 .child(Node.class,new NodeKey(nodeId));
-        return nodePath;
     }
 
     public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) {
@@ -128,8 +127,7 @@ public class SouthboundMapper {
         String uriString = SouthboundConstants.OVSDB_URI_PREFIX + "://"
                 + new String(ip.getValue()) + ":" + port.getValue();
         Uri uri = new Uri(uriString);
-        NodeId nodeId = new NodeId(uri);
-        return nodeId;
+        return new NodeId(uri);
     }
 
     public static InetAddress createInetAddress(IpAddress ip) throws UnknownHostException {
@@ -154,7 +152,7 @@ public class SouthboundMapper {
     }
 
     public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
-        String datapathtype = new String(SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class));
+        String datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class);
 
         if (mdsalbridge.getDatapathType() != null) {
             if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
index 8f72018b3822f8ff6668e5aed85f2e250852789d..dcf94d0a0aec35ba1ef81c01d873b60421b3c5ac 100644 (file)
@@ -67,14 +67,13 @@ public class ArpSender {
         checkNotNull(nodeIid);
         // node connector representing all physical ports on node
         NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(createNodeConnectorId(OFPP_ALL,
-                nodeIid.firstKeyOf(Node.class, NodeKey.class).getId()));
+                nodeIid.firstKeyOf(Node.class).getId()));
         InstanceIdentifier<NodeConnector> egressNc = nodeIid.child(NodeConnector.class, nodeConnectorKey);
         return sendArp(senderAddress, tpa, egressNc);
     }
 
     private NodeConnectorId createNodeConnectorId(String connectorId, NodeId nodeId) {
-        StringBuilder stringId = new StringBuilder(nodeId.getValue()).append(":").append(connectorId);
-        return new NodeConnectorId(stringId.toString());
+        return new NodeConnectorId(nodeId.getValue() + ":" + connectorId);
     }
 
     /**
index 38b1d5335eaa74ee5be55fd0c8ca326eeac52541..e2962a116c99b08af8faaa8d1e2fe6235b0d1f54 100644 (file)
@@ -96,23 +96,21 @@ public class MdsalHelper {
 
 
     public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
-        NodeKey nodeKey = iid.firstKeyOf(Node.class, NodeKey.class);
+        NodeKey nodeKey = iid.firstKeyOf(Node.class);
         return nodeKey.getNodeId();
     }
 
     public static InstanceIdentifier<Topology> createInstanceIdentifier() {
-        InstanceIdentifier<Topology> path = InstanceIdentifier
+        return InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID));
-        return path;
     }
 
     public static InstanceIdentifier<Node> createInstanceIdentifier(NodeId nodeId) {
-        InstanceIdentifier<Node> nodePath = InstanceIdentifier
+        return InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID))
                 .child(Node.class,new NodeKey(nodeId));
-        return nodePath;
     }
 
     public static InstanceIdentifier<Node> createInstanceIdentifier(NodeKey ovsdbNodeKey, String bridgeName) {
index 547ad2642c06230b60491193d71e22fcbcacef5a..f24d7087ca84d90d608d891eacf1faebaf8968a9 100644 (file)
@@ -220,7 +220,7 @@ public class OvsdbConnectionInstance implements OvsdbClient {
     }
 
     public NodeKey getNodeKey() {
-        return getInstanceIdentifier().firstKeyOf(Node.class, NodeKey.class);
+        return getInstanceIdentifier().firstKeyOf(Node.class);
     }
 
     public NodeId getNodeId() {
index b5252892b9351beb7fbdeeda9b5e6a945162d3c5..8480b5e1c81fca2bfba0b31f94d91523ea36d3ea 100644 (file)
@@ -61,7 +61,7 @@ public class SouthboundMapper {
     private static final Logger LOG = LoggerFactory.getLogger(SouthboundMapper.class);
 
     private static NodeId createNodeId(OvsdbConnectionInstance client) {
-        NodeKey key = client.getInstanceIdentifier().firstKeyOf(Node.class, NodeKey.class);
+        NodeKey key = client.getInstanceIdentifier().firstKeyOf(Node.class);
         return key.getNodeId();
 
     }
@@ -137,7 +137,7 @@ public class SouthboundMapper {
     }
 
     public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
-        NodeKey nodeKey = iid.firstKeyOf(Node.class, NodeKey.class);
+        NodeKey nodeKey = iid.firstKeyOf(Node.class);
         return nodeKey.getNodeId();
     }
 
@@ -210,7 +210,7 @@ public class SouthboundMapper {
     }
 
     public static Set<String> createOvsdbBridgeProtocols(OvsdbBridgeAugmentation ovsdbBridgeNode) {
-        Set<String> protocols = new HashSet<String>();
+        Set<String> protocols = new HashSet<>();
         if (ovsdbBridgeNode.getProtocolEntry() != null && ovsdbBridgeNode.getProtocolEntry().size() > 0) {
             for (ProtocolEntry protocol : ovsdbBridgeNode.getProtocolEntry()) {
                 if (SouthboundConstants.OVSDB_PROTOCOL_MAP.get(protocol.getProtocol()) != null) {
@@ -335,7 +335,7 @@ public class SouthboundMapper {
 
     public static Map<UUID, Controller> createOvsdbController(OvsdbBridgeAugmentation omn,DatabaseSchema dbSchema) {
         List<ControllerEntry> controllerEntries = omn.getControllerEntry();
-        Map<UUID,Controller> controllerMap = new HashMap<UUID,Controller>();
+        Map<UUID,Controller> controllerMap = new HashMap<>();
         if (controllerEntries != null && !controllerEntries.isEmpty()) {
             for (ControllerEntry controllerEntry : controllerEntries) {
                 String controllerNamedUUID = "Controller_" + getRandomUUID();
index 86e60e9cad4553107af0d4378e57ca3532968879..8348c99c527ce0bdb780b1a03a8a63667fa19a6f 100644 (file)
@@ -78,7 +78,7 @@ public class BridgeOperationalState {
         if (iid != null) {
             Optional<Node> nodeOptional = getBridgeNode(iid);
             if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) {
-                TerminationPointKey key = iid.firstKeyOf(TerminationPoint.class, TerminationPointKey.class);
+                TerminationPointKey key = iid.firstKeyOf(TerminationPoint.class);
                 if (key != null) {
                     for (TerminationPoint tp:nodeOptional.get().getTerminationPoint()) {
                         if (tp.getKey().equals(key)) {
@@ -103,7 +103,7 @@ public class BridgeOperationalState {
         if (iid != null) {
             Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid);
             if (ovsdbBridgeOptional.isPresent() && ovsdbBridgeOptional.get().getControllerEntry() != null) {
-                ControllerEntryKey key = iid.firstKeyOf(ControllerEntry.class, ControllerEntryKey.class);
+                ControllerEntryKey key = iid.firstKeyOf(ControllerEntry.class);
                 if (key != null) {
                     for (ControllerEntry entry: ovsdbBridgeOptional.get().getControllerEntry()) {
                         if (entry.getKey().equals(key)) {
@@ -120,7 +120,7 @@ public class BridgeOperationalState {
         if (iid != null) {
             Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid);
             if (ovsdbBridgeOptional.isPresent() && ovsdbBridgeOptional.get().getProtocolEntry() != null) {
-                ProtocolEntryKey key = iid.firstKeyOf(ProtocolEntry.class, ProtocolEntryKey.class);
+                ProtocolEntryKey key = iid.firstKeyOf(ProtocolEntry.class);
                 if (key != null) {
                     for (ProtocolEntry entry: ovsdbBridgeOptional.get().getProtocolEntry()) {
                         if (entry.getKey().equals(key)) {
index dc8bd53c94b9b40627c08cabfcfe6a5a26bed0c6..2e132d60d036f135648718cc6f6f3f22248cae7b 100644 (file)
@@ -269,7 +269,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
     }
 
     private NodeId getNodeId(OpenVSwitch ovs) {
-        NodeKey nodeKey = getInstanceIdentifier(ovs).firstKeyOf(Node.class, NodeKey.class);
+        NodeKey nodeKey = getInstanceIdentifier(ovs).firstKeyOf(Node.class);
         return nodeKey.getNodeId();
     }
 }
index 80a6ed69cc67db72cc8df6ba30b3036af490b2ec..528152aecdb74d5938f04b8a6b3161a52650a92e 100644 (file)
@@ -118,8 +118,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
             InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
         Preconditions.checkNotNull(bridgeIid);
         Preconditions.checkNotNull(bridge);
-        List<InstanceIdentifier<BridgeOtherConfigs>> result =
-                new ArrayList<InstanceIdentifier<BridgeOtherConfigs>>();
+        List<InstanceIdentifier<BridgeOtherConfigs>> result = new ArrayList<>();
 
         Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
 
@@ -143,8 +142,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
             InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
         Preconditions.checkNotNull(bridgeIid);
         Preconditions.checkNotNull(bridge);
-        List<InstanceIdentifier<BridgeExternalIds>> result =
-                new ArrayList<InstanceIdentifier<BridgeExternalIds>>();
+        List<InstanceIdentifier<BridgeExternalIds>> result = new ArrayList<>();
 
         Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
 
@@ -168,8 +166,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
             InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
         Preconditions.checkNotNull(bridgeIid);
         Preconditions.checkNotNull(bridge);
-        List<InstanceIdentifier<ProtocolEntry>> result =
-                new ArrayList<InstanceIdentifier<ProtocolEntry>>();
+        List<InstanceIdentifier<ProtocolEntry>> result = new ArrayList<>();
         Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
 
         try {
@@ -200,7 +197,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
         connectionNode.setNodeId(getOvsdbConnectionInstance().getNodeId());
 
         OvsdbNodeAugmentationBuilder ovsdbConnectionAugmentationBuilder = new OvsdbNodeAugmentationBuilder();
-        List<ManagedNodeEntry> managedBridges = new ArrayList<ManagedNodeEntry>();
+        List<ManagedNodeEntry> managedBridges = new ArrayList<>();
         InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
                 bridge);
         ManagedNodeEntry managedBridge = new ManagedNodeEntryBuilder().setBridgeRef(
@@ -266,7 +263,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
                 .getOtherConfigColumn().getData();
         if (otherConfigs != null && !otherConfigs.isEmpty()) {
             Set<String> otherConfigKeys = otherConfigs.keySet();
-            List<BridgeOtherConfigs> otherConfigList = new ArrayList<BridgeOtherConfigs>();
+            List<BridgeOtherConfigs> otherConfigList = new ArrayList<>();
             String otherConfigValue;
             for (String otherConfigKey : otherConfigKeys) {
                 otherConfigValue = otherConfigs.get(otherConfigKey);
@@ -287,7 +284,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
                 .getData();
         if (externalIds != null && !externalIds.isEmpty()) {
             Set<String> externalIdKeys = externalIds.keySet();
-            List<BridgeExternalIds> externalIdsList = new ArrayList<BridgeExternalIds>();
+            List<BridgeExternalIds> externalIdsList = new ArrayList<>();
             String externalIdValue;
             for (String externalIdKey : externalIdKeys) {
                 externalIdValue = externalIds.get(externalIdKey);
@@ -368,7 +365,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
     }
 
     private NodeId getNodeId(Bridge bridge) {
-        NodeKey nodeKey = getInstanceIdentifier(bridge).firstKeyOf(Node.class, NodeKey.class);
+        NodeKey nodeKey = getInstanceIdentifier(bridge).firstKeyOf(Node.class);
         return nodeKey.getNodeId();
     }
 }