Reorder String Equality Check in Platform Runtime
To avoid NullPointerExceptions, it is recommended to put string literals
in the left-hand-side of equals() or equalsIgnoreCase() when checking
for equality.
jSparrow Clean Up
Change-Id: Ia0a5fb0caa9e09a6afb87db30c1e7023230e3168
Signed-off-by: Ardit Ymeri <ardit.ymeri@splendit.at>
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java
index f0b1583..415d70a 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java
@@ -60,11 +60,11 @@
private static byte parsePriority(String priority) {
if (priority == null)
return ContentType.PRIORITY_NORMAL;
- if (priority.equals("high")) //$NON-NLS-1$
+ if ("high".equals(priority)) //$NON-NLS-1$
return ContentType.PRIORITY_HIGH;
- if (priority.equals("low")) //$NON-NLS-1$
+ if ("low".equals(priority)) //$NON-NLS-1$
return ContentType.PRIORITY_LOW;
- if (!priority.equals("normal")) //$NON-NLS-1$
+ if (!"normal".equals(priority)) //$NON-NLS-1$
return ContentType.PRIORITY_NORMAL;
//TODO: should log - INVALID PRIORITY
return ContentType.PRIORITY_NORMAL;
@@ -92,7 +92,7 @@
public void buildCatalog(IScopeContext context) {
IConfigurationElement[] allContentTypeCEs = getConfigurationElements();
for (IConfigurationElement allContentTypeCE : allContentTypeCEs)
- if (allContentTypeCE.getName().equals("content-type")) //$NON-NLS-1$
+ if ("content-type".equals(allContentTypeCE.getName())) //$NON-NLS-1$
registerContentType(allContentTypeCE);
for (String id : ContentTypeManager.getUserDefinedContentTypeIds(context)) {
IEclipsePreferences node = context.getNode(id);
@@ -103,7 +103,7 @@
null));
}
for (IConfigurationElement allContentTypeCE : allContentTypeCEs)
- if (allContentTypeCE.getName().equals("file-association")) //$NON-NLS-1$
+ if ("file-association".equals(allContentTypeCE.getName())) //$NON-NLS-1$
registerFileAssociation(allContentTypeCE);
applyPreferences();
}
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLContentDescriber.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLContentDescriber.java
index 331fec6..39b07ec 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLContentDescriber.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLContentDescriber.java
@@ -136,7 +136,7 @@
private boolean isNonDefaultCharset(String charset) {
if (charset == null)
return false;
- if (charset.equalsIgnoreCase("utf8") || charset.equalsIgnoreCase("utf-8")) //$NON-NLS-1$ //$NON-NLS-2$
+ if ("utf8".equalsIgnoreCase(charset) || "utf-8".equalsIgnoreCase(charset)) //$NON-NLS-1$ //$NON-NLS-2$
return false;
return true;
}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index 3bdf4cd..64d824e 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -172,7 +172,7 @@
String value = getOption(option);
if (value == null)
return defaultValue;
- return value.equalsIgnoreCase("true"); //$NON-NLS-1$
+ return "true".equalsIgnoreCase(value); //$NON-NLS-1$
}
public BundleContext getBundleContext() {
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java
index 948ed4c..559de2e 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java
@@ -247,7 +247,7 @@
if (!ENABLED)
return false;
String option = Platform.getDebugOption(eventName);
- return option != null && !option.equalsIgnoreCase("false") && !option.equalsIgnoreCase("-1"); //$NON-NLS-1$ //$NON-NLS-2$
+ return option != null && !"false".equalsIgnoreCase(option) && !"-1".equalsIgnoreCase(option); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
index e780736..202b5f9 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
@@ -709,7 +709,7 @@
String bundleName = toBundleName(baseName, locale);
ResourceBundle bundle = null;
- if (format.equals("java.properties")) { //$NON-NLS-1$
+ if ("java.properties".equals(format)) { //$NON-NLS-1$
final String resourceName = toResourceName(bundleName, "properties"); //$NON-NLS-1$
InputStream stream = null;
try {