Fix Sonar issue:
Strings literals should be placed on the left side when checking for
equality
Change-Id: I4537e08936731ace55aeecb3ad941269ec1eb191
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
index 51bb9db..c9d8f08 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
@@ -70,7 +70,7 @@
// Installs the application from input of the specified URL
private boolean installApp(ApplicationAdminService service, String url) {
try {
- if (url.equals("-")) {
+ if ("-".equals(url)) {
service.install(System.in);
} else {
service.install(new URL(url).openStream());
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
index be921cc..f8d86f1 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
@@ -63,9 +63,9 @@
// if (previousApps.contains(app.id().name())) {
// continue;
// }
- if (cmd.equals("uninstall") ||
- (cmd.equals("activate") && state == INSTALLED) ||
- (cmd.equals("deactivate") && state == ACTIVE)) {
+ if ("uninstall".equals(cmd) ||
+ ("activate".equals(cmd) && state == INSTALLED) ||
+ ("deactivate".equals(cmd) && state == ACTIVE)) {
strings.add(app.id().name());
}
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/DevicePortStateCommand.java b/cli/src/main/java/org/onosproject/cli/net/DevicePortStateCommand.java
index 798166e..c49f23e 100644
--- a/cli/src/main/java/org/onosproject/cli/net/DevicePortStateCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/DevicePortStateCommand.java
@@ -59,9 +59,9 @@
print(" %s", "Port does not exist");
return;
}
- if (portState.equals("enable")) {
+ if ("enable".equals(portState)) {
deviceAdminService.changePortState(dev.id(), pnum, true);
- } else if (portState.equals("disable")) {
+ } else if ("disable".equals(portState)) {
deviceAdminService.changePortState(dev.id(), pnum, false);
} else {
print(" %s", "State must be enable or disable");
diff --git a/cli/src/main/java/org/onosproject/cli/net/DpisListCommand.java b/cli/src/main/java/org/onosproject/cli/net/DpisListCommand.java
index 85c2dda..0533652 100644
--- a/cli/src/main/java/org/onosproject/cli/net/DpisListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/DpisListCommand.java
@@ -214,7 +214,7 @@
private void printDpiStatisticsJson(int number, DpiStatistics ds) {
String index = number < 0 ? String.format(" - ") : String.format("%5d", number);
- if (ds.receivedTime().equals("")) {
+ if ("".equals(ds.receivedTime())) {
print("ReceivedTime is null, No valid DPI Statistics!");
return;
}
@@ -233,7 +233,7 @@
return;
}
- if (ds.receivedTime().equals("")) {
+ if ("".equals(ds.receivedTime())) {
print("ReceivedTime is null, No valid DPI Statistics!");
return;
}
@@ -359,7 +359,7 @@
sb.append(String.format(" [%s pkts/", fsi.packets()));
sb.append(String.format("%s bytes]", fsi.bytes()));
String serverHostName = fsi.hostServerName();
- if (serverHostName != null && !serverHostName.equals("")) {
+ if (serverHostName != null && !"".equals(serverHostName)) {
sb.append(String.format("[Host: %s]", serverHostName));
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
index 7cbd586..c417ddc 100644
--- a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
@@ -163,7 +163,7 @@
try {
response = br.readLine();
response = response.trim().replace("\n", "");
- if (response.equals("y")) {
+ if ("y".equals(response)) {
flowService.removeFlowRules(flow);
}
} catch (IOException e) {
diff --git a/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java b/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java
index 6d9ff67..bb41497 100644
--- a/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java
@@ -252,15 +252,15 @@
private FlowEntry.FlowLiveType getFlowLiveType(String liveType) {
String liveTypeUC = liveType.toUpperCase();
- if (liveTypeUC.equals("IMMEDIATE")) {
+ if ("IMMEDIATE".equals(liveTypeUC)) {
return FlowEntry.FlowLiveType.IMMEDIATE;
- } else if (liveTypeUC.equals("SHORT")) {
+ } else if ("SHORT".equals(liveTypeUC)) {
return FlowEntry.FlowLiveType.SHORT;
- } else if (liveTypeUC.equals("MID")) {
+ } else if ("MID".equals(liveTypeUC)) {
return FlowEntry.FlowLiveType.MID;
- } else if (liveTypeUC.equals("LONG")) {
+ } else if ("LONG".equals(liveTypeUC)) {
return FlowEntry.FlowLiveType.LONG;
- } else if (liveTypeUC.equals("UNKNOWN")) {
+ } else if ("UNKNOWN".equals(liveTypeUC)) {
return FlowEntry.FlowLiveType.UNKNOWN;
} else {
return null; // flow live type error
@@ -276,19 +276,19 @@
private Instruction.Type getInstructionType(String instType) {
String instTypeUC = instType.toUpperCase();
- if (instTypeUC.equals("OUTPUT")) {
+ if ("OUTPUT".equals(instTypeUC)) {
return Instruction.Type.OUTPUT;
- } else if (instTypeUC.equals("GROUP")) {
+ } else if ("GROUP".equals(instTypeUC)) {
return Instruction.Type.GROUP;
- } else if (instTypeUC.equals("L0MODIFICATION")) {
+ } else if ("L0MODIFICATION".equals(instTypeUC)) {
return Instruction.Type.L0MODIFICATION;
- } else if (instTypeUC.equals("L2MODIFICATION")) {
+ } else if ("L2MODIFICATION".equals(instTypeUC)) {
return Instruction.Type.L2MODIFICATION;
- } else if (instTypeUC.equals("TABLE")) {
+ } else if ("TABLE".equals(instTypeUC)) {
return Instruction.Type.TABLE;
- } else if (instTypeUC.equals("L3MODIFICATION")) {
+ } else if ("L3MODIFICATION".equals(instTypeUC)) {
return Instruction.Type.L3MODIFICATION;
- } else if (instTypeUC.equals("METADATA")) {
+ } else if ("METADATA".equals(instTypeUC)) {
return Instruction.Type.METADATA;
} else {
return null; // instruction type error
diff --git a/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java
index 8c9cfcf..610a6bf 100644
--- a/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java
@@ -104,7 +104,7 @@
new TreeMap<>(Comparators.ELEMENT_COMPARATOR);
List<Group> groups;
GroupState s = null;
- if (state != null && !state.equals("any")) {
+ if (!"any".equals(state)) {
s = GroupState.valueOf(state.toUpperCase());
}
Iterable<Device> devices = deviceService.getDevices();
diff --git a/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java b/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
index 741de20..7e28afb 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
@@ -106,7 +106,7 @@
try {
response = br.readLine();
response = response.trim().replace("\n", "");
- if (response.equals("y")) {
+ if ("y".equals(response)) {
this.purgeIntents(ImmutableList.of(intent));
}
} catch (IOException e) {
diff --git a/cli/src/main/java/org/onosproject/cli/net/McastDeleteCommand.java b/cli/src/main/java/org/onosproject/cli/net/McastDeleteCommand.java
index aa026ed..f2658c8 100644
--- a/cli/src/main/java/org/onosproject/cli/net/McastDeleteCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/McastDeleteCommand.java
@@ -50,7 +50,7 @@
protected void execute() {
MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
- if (sAddr.equals("*") && gAddr.equals("*")) {
+ if ("*".equals(sAddr) && "*".equals(gAddr)) {
// Clear all routes
mcastRouteManager.getRoutes().forEach(mcastRouteManager::remove);
return;
diff --git a/cli/src/main/java/org/onosproject/cli/net/RegionUpdateCommand.java b/cli/src/main/java/org/onosproject/cli/net/RegionUpdateCommand.java
index 7ea9ec6..f0887fa 100644
--- a/cli/src/main/java/org/onosproject/cli/net/RegionUpdateCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/RegionUpdateCommand.java
@@ -78,7 +78,7 @@
List<Set<NodeId>> masters = Lists.newArrayList();
Set<NodeId> nodeIds = Sets.newHashSet();
for (String masterArg : masterArgs) {
- if (masterArg.equals("/")) {
+ if ("/".equals(masterArg)) {
masters.add(nodeIds);
nodeIds = Sets.newHashSet();
} else {
diff --git a/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java b/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java
index 9ce99be..0ebd283 100644
--- a/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java
@@ -62,7 +62,7 @@
if (accept == null) {
smService.review(appId);
printPolicy(smService, app);
- } else if (accept.trim().equals("accept")) {
+ } else if ("accept".equals(accept.trim())) {
smService.acceptPolicy(appId);
printPolicy(smService, app);
} else {