Martin Mucha has uploaded a new change for review.

Change subject: webadmin: renames & removed unnecesary explicit typing.
......................................................................

webadmin: renames & removed unnecesary explicit typing.

Change-Id: Ib5b233c5e94497ef8738dda43cf881fa54fdce6c
Signed-off-by: Martin Mucha <mmu...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
2 files changed, 71 insertions(+), 69 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/38233/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
index 4b4807f..6396042 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
@@ -121,7 +121,7 @@
 
     private Map<String, String> labelToIface;
 
-    private final List<String> networksToSync = new ArrayList<String>();
+    private final List<String> networksToSync = new ArrayList<>();
 
     // The purpose of this map is to keep the network parameters while moving 
the network from one nic to another
     private final Map<String, NetworkParameters> networkToLastDetachParams;
@@ -151,10 +151,10 @@
         setHelpTag(HelpTag.host_setup_networks);
         setHashName("host_setup_networks"); //$NON-NLS-1$
 
-        networkToLastDetachParams = new HashMap<String, NetworkParameters>();
-        netTodcParams = new HashMap<String, DcNetworkParams>();
-        netToBeforeSyncParams = new HashMap<String, NetworkParameters>();
-        setNicsChangedEvent(new 
Event<EventArgs>(NICS_CHANGED_EVENT_DEFINITION));
+        networkToLastDetachParams = new HashMap<>();
+        netTodcParams = new HashMap<>();
+        netToBeforeSyncParams = new HashMap<>();
+        setNicsChangedEvent(new Event<>(NICS_CHANGED_EVENT_DEFINITION));
         setOperationCandidateEvent(new 
Event<OperationCandidateEventArgs>(OPERATION_CANDIDATE_EVENT_DEFINITION));
         setCheckConnectivity(new EntityModel<Boolean>());
         getCheckConnectivity().setEntity(true);
@@ -231,11 +231,11 @@
     }
 
     public List<LogicalNetworkModel> getNetworks() {
-        return new ArrayList<LogicalNetworkModel>(networkMap.values());
+        return new ArrayList<>(networkMap.values());
     }
 
     public List<NetworkInterfaceModel> getNics() {
-        return new ArrayList<NetworkInterfaceModel>(nicMap.values());
+        return new ArrayList<>(nicMap.values());
     }
 
     public Event<EventArgs> getNicsChangedEvent() {
@@ -251,8 +251,8 @@
 
         Collection<String> removedLabels = labelsModel.getRemovedLabels();
         Collection<String> addedLabels = labelsModel.getAddedLabels();
-        Set<LogicalNetworkModel> removedNetworks = new 
HashSet<LogicalNetworkModel>();
-        Set<LogicalNetworkModel> addedNetworks = new 
HashSet<LogicalNetworkModel>();
+        Set<LogicalNetworkModel> removedNetworks = new HashSet<>();
+        Set<LogicalNetworkModel> addedNetworks = new HashSet<>();
         for (String label : removedLabels) {
              NetworkLabelModel networkLabelModel = networkLabelMap.get(label);
              Collection<LogicalNetworkModel> labelNetworks = networkLabelModel 
!= null ? networkLabelModel.getNetworks() : null;
@@ -267,7 +267,7 @@
             }
         }
 
-        Set<LogicalNetworkModel> potentialNetworks = new 
HashSet<LogicalNetworkModel>(originalNetworks);
+        Set<LogicalNetworkModel> potentialNetworks = new 
HashSet<>(originalNetworks);
         potentialNetworks.removeAll(removedNetworks);
         potentialNetworks.addAll(addedNetworks);
 
@@ -280,7 +280,7 @@
         NetworkInterfaceModel mockDst = new NetworkInterfaceModel(this);
         mockSrc.setEntity(new VdsNetworkInterface());
         mockDst.setEntity(new VdsNetworkInterface());
-        mockDst.setItems(new 
ArrayList<LogicalNetworkModel>(potentialNetworks));
+        mockDst.setItems(new ArrayList<>(potentialNetworks));
 
         boolean valid = !NetworkOperationFactory.operationFor(mockSrc, 
mockDst).isNullOperation();
         if (!valid) {
@@ -296,7 +296,7 @@
         labelModel.commit(iface);
         NetworkInterfaceModel ifaceModel = nicMap.get(iface.getName());
         NetworkOperation.clearNetworks(ifaceModel, allNics);
-        NetworkOperation.attachNetworks(ifaceModel, new 
ArrayList<LogicalNetworkModel>(potentialNetworks), allNics);
+        NetworkOperation.attachNetworks(ifaceModel, new 
ArrayList<>(potentialNetworks), allNics);
     }
 
     public void onEdit(NetworkItemModel<?> item) {
@@ -548,7 +548,7 @@
 
                             NetworkInterfaceModel nic1 = 
(NetworkInterfaceModel) networkCommand.getOp1();
                             NetworkInterfaceModel nic2 = 
(NetworkInterfaceModel) networkCommand.getOp2();
-                            List<LogicalNetworkModel> networks = new 
ArrayList<LogicalNetworkModel>();
+                            List<LogicalNetworkModel> networks = new 
ArrayList<>();
                             networks.addAll(nic1.getItems());
                             networks.addAll(nic2.getItems());
                             Collection<LogicalNetworkModel> potentialNetworks =
@@ -609,22 +609,23 @@
         return networkModel;
     }
 
+    //TODO MM: weird.
     private boolean equals(NetworkItemModel<?> item1, NetworkItemModel<?> 
item2) {
-        if (item1 == null && item2 == null) {
+        if (item1 == null && item2 == null) {       //item1 == item2  ??
             return true;
         }
-        return (item1 != null) ? item1.equals(item2) : item2.equals(item1);
-
+        return (item1 != null) ? item1.equals(item2) : item2.equals(item1);   
// ad after colon is always false: item1 == null, item2 != null
+        //return item1 == null ? item1 == item2 : item1.equals(item2);  
??would this be better?
     }
 
     private Collection<String> getFreeLabels() {
-        SortedSet<String> freeLabels = new TreeSet<String>(dcLabels);
+        SortedSet<String> freeLabels = new TreeSet<>(dcLabels);
         freeLabels.removeAll(labelToIface.keySet());
         return freeLabels;
     }
 
     private List<String> getFreeBonds() {
-        List<String> freeBonds = new ArrayList<String>();
+        List<String> freeBonds = new ArrayList<>();
         for (VdsNetworkInterface bond : allBonds) {
             if (!nicMap.containsKey(bond.getName())) {
                 freeBonds.add(bond.getName());
@@ -645,8 +646,8 @@
     }
 
     private void initNetworkModels() {
-        Map<String, LogicalNetworkModel> networkModels = new HashMap<String, 
LogicalNetworkModel>();
-        networkLabelMap = new HashMap<String, NetworkLabelModel>();
+        Map<String, LogicalNetworkModel> networkModels = new HashMap<>();
+        networkLabelMap = new HashMap<>();
         for (Network network : allNetworks) {
             LogicalNetworkModel networkModel = new 
LogicalNetworkModel(network, this);
             networkModels.put(network.getName(), networkModel);
@@ -666,13 +667,13 @@
     }
 
     private void initNicModels() {
-        Map<String, NetworkInterfaceModel> nicModels = new HashMap<String, 
NetworkInterfaceModel>();
-        Map<String, VdsNetworkInterface> nicMap = new HashMap<String, 
VdsNetworkInterface>();
-        List<VdsNetworkInterface> physicalNics = new 
ArrayList<VdsNetworkInterface>();
-        Map<String, List<VdsNetworkInterface>> bondToNic = new HashMap<String, 
List<VdsNetworkInterface>>();
-        Map<String, Set<LogicalNetworkModel>> nicToNetwork = new 
HashMap<String, Set<LogicalNetworkModel>>();
-        List<LogicalNetworkModel> errorLabelNetworks = new 
ArrayList<LogicalNetworkModel>();
-        labelToIface = new HashMap<String, String>();
+        Map<String, NetworkInterfaceModel> nicModels = new HashMap<>();
+        Map<String, VdsNetworkInterface> nicMap = new HashMap<>();
+        List<VdsNetworkInterface> physicalNics = new ArrayList<>();
+        Map<String, List<VdsNetworkInterface>> bondToNic = new HashMap<>();
+        Map<String, Set<LogicalNetworkModel>> nicToNetwork = new HashMap<>();
+        List<LogicalNetworkModel> errorLabelNetworks = new ArrayList<>();
+        labelToIface = new HashMap<>();
 
         // map all nics
         for (VdsNetworkInterface nic : allNics) {
@@ -697,7 +698,7 @@
                 if (bondToNic.containsKey(bondName)) {
                     bondToNic.get(bondName).add(nicMap.get(nicName));
                 } else {
-                    List<VdsNetworkInterface> bondedNics = new 
ArrayList<VdsNetworkInterface>();
+                    List<VdsNetworkInterface> bondedNics = new ArrayList<>();
                     bondedNics.add(nicMap.get(nicName));
                     bondToNic.put(bondName, bondedNics);
                 }
@@ -736,7 +737,7 @@
                     networkModel.setManagement(true);
                 }
 
-                Collection<LogicalNetworkModel> nicNetworks = new 
ArrayList<LogicalNetworkModel>();
+                Collection<LogicalNetworkModel> nicNetworks = new 
ArrayList<>();
                 nicNetworks.add(networkModel);
                 // set vlan device on the network
                 if (networkModel.hasVlan()) {
@@ -753,7 +754,7 @@
         }
 
         // calculate the next available bond name
-        List<String> bondNames = new ArrayList<String>(bondToNic.keySet());
+        List<String> bondNames = new ArrayList<>(bondToNic.keySet());
         Collections.sort(bondNames, new LexoNumericComparator());
         nextBondName = BusinessEntitiesDefinitions.BOND_NAME_PREFIX + 0;
         for (int i=0; i<bondNames.size(); ++i) {
@@ -773,7 +774,7 @@
 
             String nicName = nic.getName();
             Collection<LogicalNetworkModel> nicNetworks = 
nicToNetwork.get(nicName);
-            List<NetworkLabelModel> nicLabels = new 
ArrayList<NetworkLabelModel>();
+            List<NetworkLabelModel> nicLabels = new ArrayList<>();
 
             // does this nic have any labels?
             Set<String> labels = nic.getLabels();
@@ -807,7 +808,7 @@
             NetworkInterfaceModel nicModel;
 
             if (bondedNics != null) {
-                List<NetworkInterfaceModel> bondedModels = new 
ArrayList<NetworkInterfaceModel>();
+                List<NetworkInterfaceModel> bondedModels = new ArrayList<>();
                 for (VdsNetworkInterface bonded : bondedNics) {
                     NetworkInterfaceModel bondedModel = new 
NetworkInterfaceModel(bonded, this);
                     bondedModel.setBonded(true);
@@ -842,15 +843,16 @@
     }
 
     private void queryLabels() {
-        
AsyncDataProvider.getInstance().getNetworkLabelsByDataCenterId(getEntity().getStoragePoolId(),
 new AsyncQuery(new INewAsyncCallback() {
-            @Override
-            public void onSuccess(Object model, Object returnValue) {
-                dcLabels = (SortedSet<String>) returnValue;
+        
AsyncDataProvider.getInstance().getNetworkLabelsByDataCenterId(getEntity().getStoragePoolId(),
+                new AsyncQuery(new INewAsyncCallback() {
+                    @Override
+                    public void onSuccess(Object model, Object returnValue) {
+                        dcLabels = (SortedSet<String>) returnValue;
 
-                initNicModels();
-                stopProgress();
-            }
-        }));
+                        initNicModels();
+                        stopProgress();
+                    }
+                }));
     }
 
     private void queryFreeBonds() {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
index 0c65fc0..e3fdeaa 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
@@ -40,20 +40,20 @@
                         List<VdsNetworkInterface> allNics, Object... params) {
                     assert op1 instanceof BondNetworkInterfaceModel;
                     assert op2 == null;
-                    List<VdsNetworkInterface> bridgesToRemove = new 
ArrayList<VdsNetworkInterface>();
-                    BondNetworkInterfaceModel bond = 
(BondNetworkInterfaceModel) op1;
+                    List<VdsNetworkInterface> bridgesToRemove = new 
ArrayList<>();
+                    BondNetworkInterfaceModel bondModel = 
(BondNetworkInterfaceModel) op1;
                     // break
-                    bond.breakBond();
+                    bondModel.breakBond();
                     // detach networks
-                    List<LogicalNetworkModel> networksToDetach = new 
ArrayList<LogicalNetworkModel>();
-                    for (LogicalNetworkModel bondNetwork : bond.getItems()) {
+                    List<LogicalNetworkModel> networksToDetach = new 
ArrayList<>();
+                    for (LogicalNetworkModel bondNetwork : 
bondModel.getItems()) {
                         networksToDetach.add(bondNetwork);
                     }
                     for (LogicalNetworkModel networkToDetach : 
networksToDetach) {
                         DETACH_NETWORK.getCommand(networkToDetach, null, 
allNics).execute();
                     }
 
-                    String bondName = bond.getName();
+                    String bondName = bondModel.getName();
                     // delete bonds
                     for (VdsNetworkInterface iface : allNics) {
                         if (iface.getName().startsWith(bondName)) {
@@ -124,14 +124,14 @@
                         List<VdsNetworkInterface> allNics, Object... params) {
                     assert op1 instanceof LogicalNetworkModel;
                     assert op2 instanceof NetworkInterfaceModel;
-                    LogicalNetworkModel networkToAttach = 
(LogicalNetworkModel) op1;
-                    NetworkInterfaceModel targetNic = (NetworkInterfaceModel) 
op2;
+                    LogicalNetworkModel networkModelToAttach = 
(LogicalNetworkModel) op1;
+                    NetworkInterfaceModel targetNicModel = 
(NetworkInterfaceModel) op2;
                     // is network already attached?
-                    if (networkToAttach.isAttached()) {
+                    if (networkModelToAttach.isAttached()) {
                         // detach first
                         DETACH_NETWORK.getCommand(op1, null, 
allNics).execute();
                     }
-                    VdsNetworkInterface vlanBridge = 
networkToAttach.attach(targetNic, true);
+                    VdsNetworkInterface vlanBridge = 
networkModelToAttach.attach(targetNicModel, true);
                     if (vlanBridge != null) {
                         Iterator<VdsNetworkInterface> i = allNics.iterator();
                         // If a vlan device with the same vlan id as the new 
one already exists- remove it
@@ -176,12 +176,12 @@
                     assert op1 instanceof NetworkInterfaceModel && !(op1 
instanceof BondNetworkInterfaceModel);
                     assert op2 instanceof NetworkInterfaceModel && !(op2 
instanceof BondNetworkInterfaceModel);
                     assert params.length == 1 : "incorrect params length"; 
//$NON-NLS-1$
-                    NetworkInterfaceModel nic1 = (NetworkInterfaceModel) op1;
-                    NetworkInterfaceModel nic2 = (NetworkInterfaceModel) op2;
+                    NetworkInterfaceModel nic1Model = (NetworkInterfaceModel) 
op1;
+                    NetworkInterfaceModel nic2Model = (NetworkInterfaceModel) 
op2;
 
                     // detach possible networks from both nics
-                    clearNetworks(nic1, allNics);
-                    clearNetworks(nic2, allNics);
+                    clearNetworks(nic1Model, allNics);
+                    clearNetworks(nic2Model, allNics);
 
                     // param
                     VdsNetworkInterface bond = (VdsNetworkInterface) params[0];
@@ -190,8 +190,8 @@
                     // add to nic list
                     allNics.add(bond);
 
-                    nic1.getEntity().setBondName(bondName);
-                    nic2.getEntity().setBondName(bondName);
+                    nic1Model.getEntity().setBondName(bondName);
+                    nic2Model.getEntity().setBondName(bondName);
                 }
             };
         }
@@ -218,9 +218,9 @@
                     assert op1 instanceof BondNetworkInterfaceModel;
                     assert op2 instanceof BondNetworkInterfaceModel;
                     assert params.length == 1 : "incorrect params length"; 
//$NON-NLS-1$
-                    Set<NetworkInterfaceModel> nics = new 
HashSet<NetworkInterfaceModel>();
-                    nics.addAll(((BondNetworkInterfaceModel) op1).getBonded());
-                    nics.addAll(((BondNetworkInterfaceModel) op2).getBonded());
+                    Set<NetworkInterfaceModel> slaveModels = new HashSet<>();
+                    slaveModels.addAll(((BondNetworkInterfaceModel) 
op1).getBonded());
+                    slaveModels.addAll(((BondNetworkInterfaceModel) 
op2).getBonded());
 
                     // break both bonds
                     BREAK_BOND.getCommand(op1, null, allNics).execute();
@@ -233,8 +233,8 @@
                     // add to nic list
                     allNics.add(bond);
 
-                    for (NetworkInterfaceModel nic : nics) {
-                        nic.getEntity().setBondName(bondName);
+                    for (NetworkInterfaceModel slaveModel : slaveModels) {
+                        slaveModel.getEntity().setBondName(bondName);
                     }
                 }
             };
@@ -268,7 +268,7 @@
 
                     // Save the networks on the nic before they are detached
                     List<LogicalNetworkModel> networksToReatach =
-                            nic.getItems() != null ? new 
ArrayList<LogicalNetworkModel>(nic.getItems())
+                            nic.getItems() != null ? new 
ArrayList<>(nic.getItems())
                                     : new ArrayList<LogicalNetworkModel>();
 
                     // Detach possible networks from the nic
@@ -333,13 +333,13 @@
                         NetworkItemModel<?> op2,
                         List<VdsNetworkInterface> allNics, Object... params) {
                     assert op1 instanceof NetworkInterfaceModel;
-                    NetworkInterfaceModel nic = (NetworkInterfaceModel) op1;
-                    VdsNetworkInterface entity = nic.getEntity();
-                    entity.setBondName(null);
+                    NetworkInterfaceModel nicModel = (NetworkInterfaceModel) 
op1;
+                    VdsNetworkInterface slaveNic = nicModel.getEntity();
+                    slaveNic.setBondName(null);
                     // is there are only two nics, break the bond
-                    BondNetworkInterfaceModel bond = nic.getBond();
-                    if (bond.getBonded().size() == 2) {
-                        BREAK_BOND.getCommand(bond, null, allNics).execute();
+                    BondNetworkInterfaceModel bondModel = nicModel.getBond();
+                    if (bondModel.getBonded().size() == 2) {
+                        BREAK_BOND.getCommand(bondModel, null, 
allNics).execute();
                     }
                 }
             };
@@ -545,7 +545,7 @@
     public static void clearNetworks(NetworkInterfaceModel nic, 
List<VdsNetworkInterface> allNics) {
         List<LogicalNetworkModel> attachedNetworks = nic.getItems();
         if (attachedNetworks.size() > 0) {
-            for (LogicalNetworkModel networkModel : new 
ArrayList<LogicalNetworkModel>(attachedNetworks)) {
+            for (LogicalNetworkModel networkModel : new 
ArrayList<>(attachedNetworks)) {
                 DETACH_NETWORK.getCommand(networkModel, null, 
allNics).execute();
             }
         }


-- 
To view, visit https://gerrit.ovirt.org/38233
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5b233c5e94497ef8738dda43cf881fa54fdce6c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <mmu...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to