Use .isEmpty() instead of .size()==0 or .equals("")
Change-Id: I28f3d28e502016576424a6e301ed7bdc13147ba9
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java
index bc02026..9df2daf 100644
--- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java
+++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java
@@ -87,7 +87,7 @@
@Override
public synchronized IStackFrame[] getStackFrames() throws DebugException {
if (isSuspended()) {
- if (fFrames.size() == 0) {
+ if (fFrames.isEmpty()) {
getStackFrames0();
}
}
@@ -108,9 +108,9 @@
}
int attempts = 0;
try {
- while (fFrames.size() == 0 && !isTerminated()) {
+ while (fFrames.isEmpty() && !isTerminated()) {
fFrames.wait(50);
- if (attempts == 20 && fFrames.size() == 0 && !isTerminated()) {
+ if (attempts == 20 && fFrames.isEmpty() && !isTerminated()) {
throwDebugException(DebugModelMessages.AntThread_3);
}
attempts++;
@@ -150,7 +150,7 @@
@Override
public synchronized IStackFrame getTopStackFrame() throws DebugException {
if (isSuspended()) {
- if (fFrames.size() == 0) {
+ if (fFrames.isEmpty()) {
getStackFrames0();
}
if (fFrames.size() > 0) {
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java
index be62244..aaf6174 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java
@@ -1361,7 +1361,7 @@
OccurrencesFinder finder = new OccurrencesFinder(this, antModel, document, selection.getOffset());
positions = finder.perform();
- if (positions == null || positions.size() == 0) {
+ if (positions == null || positions.isEmpty()) {
if (!fStickyOccurrenceAnnotations) {
removeOccurrenceAnnotations();
}
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java
index 1ac9cff..a947afd 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java
@@ -421,7 +421,7 @@
* @return If the given project name is valid or not.
*/
private boolean isCurrentProjectNameValid(String currentProjectName) {
- return currentProjectName != null && !currentProjectName.equals(""); //$NON-NLS-1$
+ return currentProjectName != null && !currentProjectName.isEmpty();
}
/*
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
index 013003a..646fb97 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
@@ -236,7 +236,7 @@
targets.add(node);
}
}
- if (targets.size() == 0) {
+ if (targets.isEmpty()) {
return null;
}
return targets.toArray(new AntTargetNode[targets.size()]);
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java
index e7b58a9..d9c144a 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java
@@ -250,7 +250,7 @@
private void updateEnablement() {
boolean complete = true;
- if (fSelectedJavaProjects.size() == 0) {
+ if (fSelectedJavaProjects.isEmpty()) {
setErrorMessage(DataTransferMessages.AntBuildfileExportPage_18);
complete = false;
}
@@ -318,7 +318,7 @@
final Set<IJavaProject> projects;
try {
projects = getProjects(true);
- if (projects.size() == 0) {
+ if (projects.isEmpty()) {
return false;
}
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java
index 202d181..b919939 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java
@@ -229,7 +229,7 @@
if (vars) {
debuglevel.add("vars"); //$NON-NLS-1$
}
- if (debuglevel.size() == 0) {
+ if (debuglevel.isEmpty()) {
debuglevel.add("none"); //$NON-NLS-1$
}
variable2valueMap.put("debuglevel", ExportUtil.toString(debuglevel, ",")); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java
index 6f02632..7758930 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java
@@ -595,7 +595,7 @@
*/
public static Set<IFile> validateEdit(Shell shell, List<IFile> files) throws CoreException {
Set<IFile> confirmedFiles = new TreeSet<>(getIFileComparator());
- if (files.size() == 0) {
+ if (files.isEmpty()) {
return confirmedFiles;
}
IStatus status = files.get(0).getWorkspace().validateEdit(files.toArray(new IFile[files.size()]), shell);
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java
index f556bf5..1f30f20 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java
@@ -752,7 +752,7 @@
configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String) null);
return;
}
- } else if (fOrderedTargets.size() == 0) {
+ } else if (fOrderedTargets.isEmpty()) {
configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String) null);
return;
}
@@ -846,7 +846,7 @@
*/
@Override
public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
- if (fOrderedTargets.size() == 0) {
+ if (fOrderedTargets.isEmpty()) {
// set the dirty flag so that the state will be reinitialized on activation
setDirty(true);
}
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
index 5b3f8a1..e1fb564 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
@@ -218,7 +218,7 @@
site.setEnabled(true);
String linkname = attributes.getValue(CFG_LINK_FILE);
- if (linkname != null && !linkname.equals("")) { //$NON-NLS-1$
+ if (linkname != null && !linkname.isEmpty()) {
site.setLinkFileName(linkname.replace('/', File.separatorChar));
}
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java
index 257be99..85f7a72 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java
@@ -101,8 +101,8 @@
String id = attributes.getValue("id"); //$NON-NLS-1$
String ver = attributes.getValue("version"); //$NON-NLS-1$
- if (id == null || id.trim().equals("") //$NON-NLS-1$
- || ver == null || ver.trim().equals("")) { //$NON-NLS-1$
+ if (id == null || id.trim().isEmpty()
+ || ver == null || ver.trim().isEmpty()) {
System.out.println(NLS.bind(Messages.FeatureParser_IdOrVersionInvalid, (new String[] { id, ver})));
} else {
// String label = attributes.getValue("label"); //$NON-NLS-1$
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java
index f8ca66b..fdf5edf 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java
@@ -103,8 +103,8 @@
String id = attributes.getValue("id"); //$NON-NLS-1$
String ver = attributes.getValue("version"); //$NON-NLS-1$
- if (id == null || id.trim().equals("") //$NON-NLS-1$
- || ver == null || ver.trim().equals("")) { //$NON-NLS-1$
+ if (id == null || id.trim().isEmpty()
+ || ver == null || ver.trim().isEmpty()) {
System.out.println(NLS.bind(Messages.FeatureParser_IdOrVersionInvalid, (new String[] { id, ver})));
} else {
// String label = attributes.getValue("label"); //$NON-NLS-1$
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/SiteEntry.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/SiteEntry.java
index 41ff6d2..b518462 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/SiteEntry.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/SiteEntry.java
@@ -549,7 +549,7 @@
}
public boolean isExternallyLinkedSite() {
- return (linkFileName != null && !linkFileName.trim().equals("")); //$NON-NLS-1$
+ return (linkFileName != null && !linkFileName.trim().isEmpty());
}
public synchronized void refresh() {
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java
index b3e5fcd..80c76d2 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java
@@ -351,7 +351,7 @@
String s = string.trim();
- if (s.equals("")) //$NON-NLS-1$
+ if (s.isEmpty())
return string;
if (!s.startsWith(KEY_PREFIX))