Allon Mureinik has uploaded a new change for review.

Change subject: engine: Remove "not null and equals" calls
......................................................................

engine: Remove "not null and equals" calls

Checking nullness before comparing to a constant is redundant in Java,
since equals(Object) already handles null values.

I.e., instead of calling:
var != null && var.equals(constant)

we should call
constant.equals(var)

This is both faster and easier to read.

Change-Id: I062415b8e09c7ff39d54e4561e5034aa85540949
Signed-off-by: Allon Mureinik <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
3 files changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/56/18656/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java
index 3a2542f..74877f6 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java
@@ -98,7 +98,7 @@
         ArrayList<Integer> oss = new ArrayList<Integer>();
         for (int osId : getOsIds()) {
             String bus = getValueByVersion(idToUnameLookup.get(osId), "bus", 
null);
-            if (bus != null && bus.equalsIgnoreCase("64")) {
+            if ("64".equalsIgnoreCase(bus)) {
                 oss.add(osId);
             }
         }
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
index a2fab70..210eb7d 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
@@ -190,7 +190,7 @@
     }
 
     private static void handleNotLoggedInEvent(String errorMessage) {
-        if (errorMessage != null && 
errorMessage.equals("USER_IS_NOT_LOGGED_IN")) { //$NON-NLS-1$
+        if ("USER_IS_NOT_LOGGED_IN".equals(errorMessage)) { //$NON-NLS-1$
             frontendNotLoggedInEvent.raise(Frontend.class, EventArgs.Empty);
         }
     }
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 e4d5c6d..c74d0b2 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
@@ -170,15 +170,15 @@
         NetworkInterfaceModel nic2 = null;
         LogicalNetworkModel network2 = null;
 
-        if (op1Type != null && op1Type.equals(NIC)) {
+        if (NIC.equals(op1Type)) {
             nic1 = nicMap.get(op1Key);
-        } else if (op1Type != null && op1Type.equals(NETWORK)) {
+        } else if (NETWORK.equals(op1Type)) {
             network1 = networkMap.get(op1Key);
         }
 
-        if (op2Type != null && op2Type.equals(NIC)) {
+        if (NIC.equals(op2Type)) {
             nic2 = nicMap.get(op2Key);
-        } else if (op2Type != null && op2Type.equals(NETWORK)) {
+        } else if (NETWORK.equals(op2Type)) {
             network2 = networkMap.get(op2Key);
         }
 


-- 
To view, visit http://gerrit.ovirt.org/18656
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I062415b8e09c7ff39d54e4561e5034aa85540949
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to