Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2016-04-19 06:35:21 -0400
committerGerrit Code Review @ Eclipse.org2016-04-19 13:35:54 -0400
commit2114f6b108763ff027fe0936e1f7b4d7e9cc655c (patch)
treeafd55872d8d3dae5de15300ef63cc6acffdc6e92 /build/org.eclipse.cdt.managedbuilder.ui
parent10ba077124e266fb7cfa661241d044a3ee91e0d3 (diff)
downloadorg.eclipse.cdt-2114f6b108763ff027fe0936e1f7b4d7e9cc655c.tar.gz
org.eclipse.cdt-2114f6b108763ff027fe0936e1f7b4d7e9cc655c.tar.xz
org.eclipse.cdt-2114f6b108763ff027fe0936e1f7b4d7e9cc655c.zip
Bug 491984 - Replace .equals("") with .isEmpty()
In many cases a String's empty status is tested with `.equals("")`. However, Java 1.6 added `.isEmpty()` which can be more efficient since it compares the internal length parameter only for testing. Replace code using the `.isEmpty()` variant instead. Some tests for `"".equals(expr)` can be replaced with `expr.isEmpty()` where it is already known that the `expr` is not null; however, these have to be reviewed on a case-by-case basis. Change-Id: I3c6af4d8b7638e757435914ac76cb3a67899a5fd Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingUI.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewBuildConfigurationDialog.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java2
5 files changed, 12 insertions, 12 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
index a9131a7e76..2c89993142 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
@@ -60,7 +60,7 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
public BuildOptionComboFieldEditor(String name, String label, String tooltip, String contextId, String [] opts, String sel, Composite parent) {
this(name, label, opts, sel, parent);
setToolTip(tooltip);
- if (!contextId.equals("")) PlatformUI.getWorkbench().getHelpSystem().setHelp(optionSelector, contextId); //$NON-NLS-1$
+ if (!contextId.isEmpty()) PlatformUI.getWorkbench().getHelpSystem().setHelp(optionSelector, contextId);
}
/**
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingUI.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingUI.java
index 668e8ac531..48d2104885 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingUI.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others.
+ * Copyright (c) 2004, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -314,7 +314,7 @@ public class BuildToolSettingUI extends AbstractToolSettingUI {
optionValueExist = true;
}
}
- if (!enumeration.equals("")) //$NON-NLS-1$
+ if (!enumeration.isEmpty())
setOption(opt, enumeration);
break;
case IOption.TREE :
@@ -328,7 +328,7 @@ public class BuildToolSettingUI extends AbstractToolSettingUI {
optionValueExist = true;
}
}
- if (!selectedID.equals("")) //$NON-NLS-1$
+ if (!selectedID.isEmpty())
setOption(opt, selectedID);
break;
case IOption.STRING_LIST :
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java
index e74b00b901..9e6bae401c 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 BitMethods Inc and others.
+ * Copyright (c) 2004, 2016 BitMethods Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -89,7 +89,7 @@ public class FileListControlFieldEditor extends FieldEditor {
this(name, labelText, parent, type);
// can't use setToolTip(tooltip) as label not created yet
getLabelControl(parent).setToolTipText(tooltip);
- if (!contextId.equals("")) PlatformUI.getWorkbench().getHelpSystem().setHelp(list.getListControl(), contextId); //$NON-NLS-1$
+ if (!contextId.isEmpty()) PlatformUI.getWorkbench().getHelpSystem().setHelp(list.getListControl(), contextId);
}
/**
@@ -299,7 +299,7 @@ public class FileListControlFieldEditor extends FieldEditor {
* @return
*/
private String createList(String[] items) {
- StringBuffer path = new StringBuffer(""); //$NON-NLS-1$
+ StringBuffer path = new StringBuffer();
for (int i = 0; i < items.length; i++) {
path.append(items[i]);
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewBuildConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewBuildConfigurationDialog.java
index b8d0218048..d037e40b0b 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewBuildConfigurationDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewBuildConfigurationDialog.java
@@ -122,7 +122,7 @@ public class NewBuildConfigurationDialog extends Dialog {
for (int i = 0; i < definedCfgds.length; i++) {
description = definedCfgds[i].getDescription();
- if( (description == null) || (description.equals("")) ){ //$NON-NLS-1$
+ if( (description == null) || (description.isEmpty()) ){
nameAndDescription = definedCfgds[i].getName();
} else {
nameAndDescription = definedCfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -138,7 +138,7 @@ public class NewBuildConfigurationDialog extends Dialog {
for (int i = 0; i < defaultCfgds.length; i++) {
description = defaultCfgds[i].getDescription();
- if( (description == null) || (description.equals("")) ) { //$NON-NLS-1$
+ if( (description == null) || (description.isEmpty()) ) {
nameAndDescription = defaultCfgds[i].getName();
} else {
nameAndDescription = defaultCfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -330,7 +330,7 @@ public class NewBuildConfigurationDialog extends Dialog {
if(defaultCfgds.length != 0){
String namesAndDescriptions[] = new String[defaultCfgds.length];
for (int i = 0; i < defaultCfgds.length; ++i) {
- if ( (defaultCfgds[i].getDescription() == null) || defaultCfgds[i].getDescription().equals("")) //$NON-NLS-1$
+ if ( (defaultCfgds[i].getDescription() == null) || defaultCfgds[i].getDescription().isEmpty())
namesAndDescriptions[i] = defaultCfgds[i].getName();
else
namesAndDescriptions[i] = defaultCfgds[i].getName() + "( " + defaultCfgds[i].getDescription() + " )"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -362,7 +362,7 @@ public class NewBuildConfigurationDialog extends Dialog {
private String [] getDefinedConfigNamesAndDescriptions() {
String [] namesAndDescriptions = new String[definedCfgds.length];
for (int i = 0; i < definedCfgds.length; ++i) {
- if ( (definedCfgds[i].getDescription() == null) || definedCfgds[i].getDescription().equals("")) //$NON-NLS-1$
+ if ( (definedCfgds[i].getDescription() == null) || definedCfgds[i].getDescription().isEmpty())
namesAndDescriptions[i] = definedCfgds[i].getName();
else
namesAndDescriptions[i] = definedCfgds[i].getName() + "( " + definedCfgds[i].getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java
index 608814b92d..6b10300156 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java
@@ -481,7 +481,7 @@ public class NewCfgDialog implements INewCfgDialog {
private String getNameAndDescription(IConfiguration cfg) {
String name = cfg.getName();
if (name == null) name = NULL;
- if ( (cfg.getDescription() == null) || cfg.getDescription().equals("")) //$NON-NLS-1$
+ if ( (cfg.getDescription() == null) || cfg.getDescription().isEmpty())
return name;
else
return name + "( " + cfg.getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$

Back to the top