A few cleanups 67/27067/1
authorFlavio Fernandes <ffernand@redhat.com>
Wed, 16 Sep 2015 06:19:35 +0000 (02:19 -0400)
committerFlavio Fernandes <ffernand@redhat.com>
Wed, 16 Sep 2015 20:53:46 +0000 (16:53 -0400)
* use plain String concatenation instead of StringBuilder where appropriate
* simplify single-use return variables
* <> operator
* avoid calling new String()

Change-Id: I56e99426daeda620a37059417588e5ee4fb99c76
Also-By: Stephen Kitt <skitt@redhat.com>
Signed-off-by: Flavio Fernandes <ffernand@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/SouthboundMapper.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..1030915e53a35df66f7f6e9267f9d335c4cf3189 100644 (file)
@@ -73,8 +73,7 @@ public class ArpSender {
     }
 
     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..87fc3e0c2f47f2caa8745fd9a49ef7e7c72d6410 100644 (file)
@@ -101,18 +101,16 @@ public class MdsalHelper {
     }
 
     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 b5252892b9351beb7fbdeeda9b5e6a945162d3c5..b49f50ed6a0760f18e5f9aca32262d2a2a0c6b70 100644 (file)
@@ -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 80a6ed69cc67db72cc8df6ba30b3036af490b2ec..55aba8b987f0e101d2d38eaeaa1ba8a57e04ae3a 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);