Fix Sonar issue:
Strings literals should be placed on the left side when checking for
equality
Change-Id: I4537e08936731ace55aeecb3ad941269ec1eb191
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java
index ce85758..416bbf14 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java
@@ -131,7 +131,7 @@
String metadataUri = System.getProperty("onos.cluster.metadata.uri");
try {
String protocol = metadataUri == null ? null : new URL(metadataUri).getProtocol();
- if (protocol != null && (!protocol.equals("file") && !protocol.equals("http"))) {
+ if (!"file".equals(protocol) && !"http".equals(protocol)) {
return getProvider(protocol);
}
// file provider supports both "file" and "http" uris
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java b/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
index 6db0365..706e286 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
@@ -166,10 +166,10 @@
public boolean isAvailable() {
try {
URL url = new URL(metadataUrl);
- if (url.getProtocol().equals("file")) {
+ if ("file".equals(url.getProtocol())) {
File file = new File(metadataUrl.replaceFirst("file://", ""));
return file.exists();
- } else if (url.getProtocol().equals("http")) {
+ } else if ("http".equals(url.getProtocol())) {
try (InputStream file = url.openStream()) {
return true;
}
@@ -188,11 +188,11 @@
URL url = new URL(metadataUrl);
ClusterMetadata metadata = null;
long version = 0;
- if (url.getProtocol().equals("file")) {
+ if ("file".equals(url.getProtocol())) {
File file = new File(metadataUrl.replaceFirst("file://", ""));
version = file.lastModified();
metadata = mapper.readValue(new FileInputStream(file), ClusterMetadata.class);
- } else if (url.getProtocol().equals("http")) {
+ } else if ("http".equals(url.getProtocol())) {
URLConnection conn = url.openConnection();
version = conn.getLastModified();
metadata = mapper.readValue(conn.getInputStream(), ClusterMetadata.class);
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/MastershipManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/MastershipManager.java
index ae9dc16..c36ad62 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/MastershipManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/MastershipManager.java
@@ -128,7 +128,7 @@
public void modified() {
Set<ConfigProperty> configProperties = cfgService.getProperties(getClass().getCanonicalName());
for (ConfigProperty property : configProperties) {
- if (property.name().equals("useRegionForBalanceRoles")) {
+ if ("useRegionForBalanceRoles".equals(property.name())) {
useRegionForBalanceRoles = property.asBoolean();
}
}