Skip to content

Commit ba1a105

Browse files
committed
Improvement: replace all occurrences of the .equals("") usages with .isEmpty()
1 parent 1262ae3 commit ba1a105

File tree

152 files changed

+236
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+236
-236
lines changed

make/jdk/src/classes/build/tools/compileproperties/CompileProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private static boolean createFile(String propertiesPath, String outputPath,
260260
}
261261

262262
String packageString = "";
263-
if (packageName != null && !packageName.equals("")) {
263+
if (packageName != null && !packageName.isEmpty()) {
264264
packageString = "package " + packageName + ";\n\n";
265265
}
266266

make/jdk/src/classes/build/tools/generatebreakiteratordata/CharacterCategory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static void main(String[] args) {
119119
* Generates data in older format (1.4.X and earlier) and creates
120120
* the old CategoryMap if "oldFilename" is not null.
121121
*/
122-
if (!oldDatafile.equals("")) {
122+
if (!oldDatafile.isEmpty()) {
123123
generateOldData();
124124
generateOldDatafile();
125125
}

make/jdk/src/classes/build/tools/generatebreakiteratordata/GenerateBreakIteratorData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ private static void processArgs(String[] args) {
161161
* Make locale name ("_language_country_valiant")
162162
*/
163163
private static String getLocaleName() {
164-
if (language.equals("")) {
165-
if (!country.equals("") || !valiant.equals("")) {
164+
if (language.isEmpty()) {
165+
if (!country.isEmpty() || !valiant.isEmpty()) {
166166
language = "en";
167167
} else {
168168
return "";
@@ -172,10 +172,10 @@ private static String getLocaleName() {
172172
StringBuffer sb = new StringBuffer();
173173
sb.append('_');
174174
sb.append(language);
175-
if (!country.equals("") || !valiant.equals("")) {
175+
if (!country.isEmpty() || !valiant.isEmpty()) {
176176
sb.append('_');
177177
sb.append(country);
178-
if (!valiant.equals("")) {
178+
if (!valiant.isEmpty()) {
179179
sb.append('_');
180180
sb.append(valiant);
181181
}

make/jdk/src/classes/build/tools/generatebreakiteratordata/RuleBasedBreakIteratorBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ protected void writeTables(String datafile) {
20222022
final String outputDir;
20232023
String tmpbuf = GenerateBreakIteratorData.getOutputDirectory();
20242024

2025-
if (tmpbuf.equals("")) {
2025+
if (tmpbuf.isEmpty()) {
20262026
filename = datafile;
20272027
outputDir = "";
20282028
} else {
@@ -2039,7 +2039,7 @@ protected void writeTables(String datafile) {
20392039
}
20402040

20412041
try {
2042-
if (!outputDir.equals("")) {
2042+
if (!outputDir.isEmpty()) {
20432043
new File(outputDir).mkdirs();
20442044
}
20452045
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(filename));

make/jdk/src/classes/build/tools/pandocfilter/json/JSONParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public JSONValue parseValue() {
375375
}
376376

377377
public JSONValue parse(String s) {
378-
if (s == null || s.equals("")) {
378+
if (s == null || s.isEmpty()) {
379379
return null;
380380
}
381381

make/langtools/tools/anttasks/SelectToolTask.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void execute() {
151151
}
152152

153153
// finally, return required values, if any
154-
if (toolProperty != null && !(toolName == null || toolName.equals(""))) {
154+
if (toolProperty != null && !(toolName == null || toolName.isEmpty())) {
155155
p.setProperty(toolProperty, toolName);
156156

157157
if (argsProperty != null && toolArgs != null)
@@ -169,7 +169,7 @@ void showGUI(Properties fileProps) {
169169
toolName = tool.toolName;
170170
toolArgs = argsField.getText();
171171
if (defaultCheck.isSelected()) {
172-
if (toolName.equals("")) {
172+
if (toolName.isEmpty()) {
173173
fileProps.remove("tool.name");
174174
fileProps.remove("tool.bootstrap");
175175
} else {
@@ -243,7 +243,7 @@ public void focusLost(FocusEvent e) {
243243

244244
final JOptionPane p = new JOptionPane(body);
245245
okButton = new JButton("OK");
246-
okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
246+
okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.isEmpty()));
247247
okButton.addActionListener(e -> {
248248
JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
249249
d.setVisible(false);
@@ -304,7 +304,7 @@ String getDefaultArgsForTool(Properties props, ToolChoices tool) {
304304
if (tool == null)
305305
return "";
306306
String toolName = tool.toolName;
307-
return toolName.equals("") ? "" : props.getProperty(toolName + ".args", "");
307+
return toolName.isEmpty() ? "" : props.getProperty(toolName + ".args", "");
308308
}
309309

310310
// Ant task parameters

make/langtools/tools/compileproperties/CompileProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private boolean createFile(String propertiesPath, String outputPath,
247247
}
248248

249249
String packageString = "";
250-
if (packageName != null && !packageName.equals("")) {
250+
if (packageName != null && !packageName.isEmpty()) {
251251
packageString = "package " + packageName + ";\n\n";
252252
}
253253

src/demo/share/java2d/J2DBench/src/j2dbench/tests/iio/InputImageTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static void initIIOReadFormats() {
184184
String klass = spi.getClass().getName();
185185
String format = spi.getFormatNames()[0].toLowerCase();
186186
String suffix = spi.getFileSuffixes()[0].toLowerCase();
187-
if (suffix == null || suffix.equals("")) {
187+
if (suffix == null || suffix.isEmpty()) {
188188
suffix = format;
189189
}
190190
String shortName;

src/demo/share/java2d/J2DBench/src/j2dbench/tests/iio/OutputImageTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static void initIIOWriteFormats() {
143143
String klass = spi.getClass().getName();
144144
String format = spi.getFormatNames()[0].toLowerCase();
145145
String suffix = spi.getFileSuffixes()[0].toLowerCase();
146-
if (suffix == null || suffix.equals("")) {
146+
if (suffix == null || suffix.isEmpty()) {
147147
suffix = format;
148148
}
149149
String shortName;

src/demo/share/jfc/TableExample/JDBCAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void setValueAt(Object value, int row, int column) {
246246
// that editing is possible, we'll just lock on everything.
247247
for (int col = 0; col < getColumnCount(); col++) {
248248
String colName = getColumnName(col);
249-
if (colName.equals("")) {
249+
if (colName.isEmpty()) {
250250
continue;
251251
}
252252
if (col != 0) {

0 commit comments

Comments
 (0)