Fix Sonar issue:
Strings literals should be placed on the left side when checking for
equality
Change-Id: I4537e08936731ace55aeecb3ad941269ec1eb191
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java
index 52ecde6..2d1bae6 100644
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java
+++ b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java
@@ -697,11 +697,11 @@
}
if ((flowClassifier.protocol() != null) && (!flowClassifier.protocol().isEmpty())) {
- if (flowClassifier.protocol().equalsIgnoreCase("TCP")) {
+ if ("TCP".equalsIgnoreCase(flowClassifier.protocol())) {
selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_TCP));
- } else if (flowClassifier.protocol().equalsIgnoreCase("UDP")) {
+ } else if ("UDP".equalsIgnoreCase(flowClassifier.protocol())) {
selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_UDP));
- } else if (flowClassifier.protocol().equalsIgnoreCase("ICMP")) {
+ } else if ("ICMP".equalsIgnoreCase(flowClassifier.protocol())) {
selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_ICMP));
}
} else if (fiveTuple != null && fiveTuple.protocol() != 0) {
@@ -709,8 +709,8 @@
}
if (((flowClassifier.etherType() != null) && (!flowClassifier.etherType().isEmpty()))
- && (flowClassifier.etherType().equals("IPv4") || flowClassifier.etherType().equals("IPv6"))) {
- if (flowClassifier.etherType().equals("IPv4")) {
+ && ("IPv4".equals(flowClassifier.etherType()) || "IPv6".equals(flowClassifier.etherType()))) {
+ if ("IPv4".equals(flowClassifier.etherType())) {
selector.matchEthType(Ethernet.TYPE_IPV4);
} else {
selector.matchEthType(Ethernet.TYPE_IPV6);
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java
index eb63917..d429fc9 100644
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java
+++ b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java
@@ -407,11 +407,11 @@
boolean match = false;
// Check whether protocol is set in flow classifier
if (flowClassifier.protocol() != null) {
- if ((flowClassifier.protocol().equalsIgnoreCase("TCP")
+ if (("TCP".equalsIgnoreCase(flowClassifier.protocol())
&& fiveTuple.protocol() == IPv4.PROTOCOL_TCP)
- || (flowClassifier.protocol().equalsIgnoreCase("UDP")
+ || ("UDP".equalsIgnoreCase(flowClassifier.protocol())
&& fiveTuple.protocol() == IPv4.PROTOCOL_UDP)
- || (flowClassifier.protocol().equalsIgnoreCase("ICMP")
+ || ("ICMP".equalsIgnoreCase(flowClassifier.protocol())
&& fiveTuple.protocol() == IPv4.PROTOCOL_ICMP)) {
match = true;
} else {
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java
index f1fcbbc..cb44b5d 100644
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java
+++ b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java
@@ -644,7 +644,7 @@
Subnet subnet = subnetService.getSubnet(subnetId);
String deviceOwner = virtualPort.deviceOwner();
if (deviceOwner != null) {
- if (deviceOwner.equalsIgnoreCase("network:dhcp")) {
+ if ("network:dhcp".equalsIgnoreCase(deviceOwner)) {
Sets.newHashSet(devices).stream()
.filter(d -> d.type() == Device.Type.SWITCH)
.forEach(d -> {
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
index 026a8ac..200ce09 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
@@ -123,13 +123,13 @@
}
private State isState(String state) {
- if (state.equals("ACTIVE")) {
+ if ("ACTIVE".equals(state)) {
return TenantNetwork.State.ACTIVE;
- } else if (state.equals("BUILD")) {
+ } else if ("BUILD".equals(state)) {
return TenantNetwork.State.BUILD;
- } else if (state.equals("DOWN")) {
+ } else if ("DOWN".equals(state)) {
return TenantNetwork.State.DOWN;
- } else if (state.equals("ERROR")) {
+ } else if ("ERROR".equals(state)) {
return TenantNetwork.State.ERROR;
} else {
return null;
@@ -137,7 +137,7 @@
}
private Type isType(String type) {
- if (type.equals("LOCAL")) {
+ if ("LOCAL".equals(type)) {
return TenantNetwork.Type.LOCAL;
} else {
return null;
@@ -286,7 +286,7 @@
String segmentationIdStr = node.get("provider:segmentation_id").asText();
SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdStr);
TenantId tenantId = TenantId.tenantId(tenantIdStr);
- if (segmentationIdStr == null || segmentationIdStr.equals("null")) {
+ if (segmentationIdStr == null || "null".equals(segmentationIdStr)) {
segmentationId = get(VtnRscService.class).getL3vni(tenantId);
}
TenantNetworkId id = null;
@@ -337,7 +337,7 @@
String segmentationIdStr = node.get("provider:segmentation_id").asText();
SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdStr);
TenantId tenantId = TenantId.tenantId(tenantIdStr);
- if (segmentationIdStr == null || segmentationIdStr.equals("null")) {
+ if (segmentationIdStr == null || "null".equals(segmentationIdStr)) {
segmentationId = get(VtnRscService.class).getL3vni(tenantId);
}
network = new DefaultTenantNetwork(
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
index 1e1cc79..af82f9b 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
@@ -387,7 +387,7 @@
* @return the virtualPort state
*/
private State isState(String state) {
- if (state.equals("ACTIVE")) {
+ if ("ACTIVE".equals(state)) {
return VirtualPort.State.ACTIVE;
} else {
return VirtualPort.State.DOWN;
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java
index cd61280..05cfaae 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java
@@ -60,36 +60,36 @@
Iterator<String> i = fields.iterator();
while (i.hasNext()) {
String s = i.next();
- if (s.equals("floating_network_id")) {
+ if ("floating_network_id".equals(s)) {
result.put("floating_network_id", floatingIp.networkId()
.toString());
}
- if (s.equals("router_id")) {
+ if ("router_id".equals(s)) {
result.put("router_id",
floatingIp.routerId() == null ? null : floatingIp
.routerId().routerId());
}
- if (s.equals("tenant_id")) {
+ if ("tenant_id".equals(s)) {
result.put("tenant_id", floatingIp.tenantId().toString());
}
- if (s.equals("port_id")) {
+ if ("port_id".equals(s)) {
result.put("port_id",
floatingIp.portId() == null ? null : floatingIp
.portId().toString());
}
- if (s.equals("id")) {
+ if ("id".equals(s)) {
result.put("id", floatingIp.id().floatingIpId().toString());
}
- if (s.equals("fixed_ip_address")) {
+ if ("fixed_ip_address".equals(s)) {
result.put("fixed_ip_address",
floatingIp.fixedIp() == null ? null : floatingIp
.fixedIp().toString());
}
- if (s.equals("floating_ip_address")) {
+ if ("floating_ip_address".equals(s)) {
result.put("floating_ip_address", floatingIp.floatingIp()
.toString());
}
- if (s.equals("status")) {
+ if ("status".equals(s)) {
result.put("status", floatingIp.status().toString());
}
}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
index e4d4b93..c760c9c 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
@@ -75,12 +75,12 @@
String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setEtherType(etherType);
- if (json.get(PROTOCOL) != null && !(json.get(PROTOCOL)).asText().equals("null")) {
+ if (json.get(PROTOCOL) != null && !"null".equals((json.get(PROTOCOL)).asText())) {
String protocol = (json.get(PROTOCOL)).asText();
resultBuilder.setProtocol(protocol);
}
- if (json.get(PRIORITY) != null && !(json.get(PRIORITY)).asText().equals("null")) {
+ if (json.get(PRIORITY) != null && !"null".equals((json.get(PRIORITY)).asText())) {
int priority = (json.get(PRIORITY)).asInt();
resultBuilder.setPriority(priority);
}
@@ -97,22 +97,22 @@
int maxDstPortRange = (json.get(MAX_DST_PORT_RANGE)).asInt();
resultBuilder.setMaxDstPortRange(maxDstPortRange);
- if (json.get(SRC_IP_PREFIX) != null && !(json.get(SRC_IP_PREFIX)).asText().equals("null")) {
+ if (json.get(SRC_IP_PREFIX) != null && !"null".equals((json.get(SRC_IP_PREFIX)).asText())) {
String srcIpPrefix = (json.get(SRC_IP_PREFIX)).asText();
resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix));
}
- if (json.get(DST_IP_PREFIX) != null && !(json.get(DST_IP_PREFIX)).asText().equals("null")) {
+ if (json.get(DST_IP_PREFIX) != null && !"null".equals((json.get(DST_IP_PREFIX)).asText())) {
String dstIpPrefix = (json.get(DST_IP_PREFIX)).asText();
resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix));
}
- if (json.get(SRC_PORT) != null && !(json.get(SRC_PORT)).asText().equals("null")) {
+ if (json.get(SRC_PORT) != null && !"null".equals((json.get(SRC_PORT)).asText())) {
String srcPort = (json.get(SRC_PORT)).asText();
resultBuilder.setSrcPort(VirtualPortId.portId(srcPort));
}
- if (json.get(DST_PORT) != null && !(json.get(DST_PORT)).asText().equals("null")) {
+ if (json.get(DST_PORT) != null && !"null".equals((json.get(DST_PORT)).asText())) {
String dstPort = (json.get(DST_PORT)).asText();
resultBuilder.setDstPort(VirtualPortId.portId(dstPort));
}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java
index b6819b2..b602108 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java
@@ -59,26 +59,26 @@
Iterator<String> i = fields.iterator();
while (i.hasNext()) {
String s = i.next();
- if (s.equals("id")) {
+ if ("id".equals(s)) {
result.put("id", router.id().routerId());
}
- if (s.equals("status")) {
+ if ("status".equals(s)) {
result.put("status", router.status().toString());
}
- if (s.equals("name")) {
+ if ("name".equals(s)) {
result.put("name", router.name().toString());
}
- if (s.equals("admin_state_up")) {
+ if ("admin_state_up".equals(s)) {
result.put("admin_state_up", router.adminStateUp());
}
- if (s.equals("tenant_id")) {
+ if ("tenant_id".equals(s)) {
result.put("tenant_id", router.tenantId().toString());
}
- if (s.equals("routes")) {
+ if ("routes".equals(s)) {
result.put("routes", router.routes() == null ? null : router
.routes().toString());
}
- if (s.equals("external_gateway_info")) {
+ if ("external_gateway_info".equals(s)) {
result.set("external_gateway_info",
router.externalGatewayInfo() == null ? null
: new RouterGatewayInfoCodec()