Merge pull request #23550 from sann3
* pr/23550: Polish "Polish empty string checks" Polish empty string checks Closes gh-23550
This commit is contained in:
		
						commit
						ec0fae883c
					
				|  | @ -290,7 +290,7 @@ public class RabbitProperties { | |||
| 	} | ||||
| 
 | ||||
| 	public void setVirtualHost(String virtualHost) { | ||||
| 		this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost; | ||||
| 		this.virtualHost = StringUtils.hasText(virtualHost) ? virtualHost : "/"; | ||||
| 	} | ||||
| 
 | ||||
| 	public AddressShuffleMode getAddressShuffleMode() { | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2012-2019 the original author or authors. | ||||
|  * Copyright 2012-2020 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -33,6 +33,7 @@ import jline.console.completer.StringsCompleter; | |||
| import org.springframework.boot.cli.command.Command; | ||||
| import org.springframework.boot.cli.command.options.OptionHelp; | ||||
| import org.springframework.boot.cli.util.Log; | ||||
| import org.springframework.util.StringUtils; | ||||
| 
 | ||||
| /** | ||||
|  * JLine {@link Completer} for Spring Boot {@link Command}s. | ||||
|  | @ -74,7 +75,7 @@ public class CommandCompleter extends StringsCompleter { | |||
| 		int completionIndex = super.complete(buffer, cursor, candidates); | ||||
| 		int spaceIndex = buffer.indexOf(' '); | ||||
| 		String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : ""); | ||||
| 		if (!"".equals(commandName.trim())) { | ||||
| 		if (StringUtils.hasText(commandName)) { | ||||
| 			for (Command command : this.commands) { | ||||
| 				if (command.getName().equals(commandName)) { | ||||
| 					if (cursor == buffer.length() && buffer.endsWith(" ")) { | ||||
|  |  | |||
|  | @ -298,7 +298,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor | |||
| 	private void processEndpoint(AnnotationMirror annotation, TypeElement element) { | ||||
| 		Map<String, Object> elementValues = this.metadataEnv.getAnnotationElementValues(annotation); | ||||
| 		String endpointId = (String) elementValues.get("id"); | ||||
| 		if (endpointId == null || "".equals(endpointId)) { | ||||
| 		if (endpointId == null || endpointId.isEmpty()) { | ||||
| 			return; // Can't process that endpoint | ||||
| 		} | ||||
| 		String endpointKey = ItemMetadata.newItemMetadataPrefix("management.endpoint.", endpointId); | ||||
|  |  | |||
|  | @ -180,8 +180,8 @@ class MetadataGenerationEnvironment { | |||
| 			reason = (String) elementValues.get("reason"); | ||||
| 			replacement = (String) elementValues.get("replacement"); | ||||
| 		} | ||||
| 		reason = "".equals(reason) ? null : reason; | ||||
| 		replacement = "".equals(replacement) ? null : replacement; | ||||
| 		reason = (reason == null || reason.isEmpty()) ? null : reason; | ||||
| 		replacement = (replacement == null || replacement.isEmpty()) ? null : replacement; | ||||
| 		return new ItemDeprecation(reason, replacement); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -180,7 +180,7 @@ class TypeUtils { | |||
| 		if (javadoc != null) { | ||||
| 			javadoc = NEW_LINE_PATTERN.matcher(javadoc).replaceAll("").trim(); | ||||
| 		} | ||||
| 		return "".equals(javadoc) ? null : javadoc; | ||||
| 		return (javadoc == null || javadoc.isEmpty()) ? null : javadoc; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2012-2019 the original author or authors. | ||||
|  * Copyright 2012-2020 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -171,7 +171,7 @@ public class ConfigurationMetadata { | |||
| 	public static String nestedPrefix(String prefix, String name) { | ||||
| 		String nestedPrefix = (prefix != null) ? prefix : ""; | ||||
| 		String dashedName = toDashedCase(name); | ||||
| 		nestedPrefix += "".equals(nestedPrefix) ? dashedName : "." + dashedName; | ||||
| 		nestedPrefix += (nestedPrefix == null || nestedPrefix.isEmpty()) ? dashedName : "." + dashedName; | ||||
| 		return nestedPrefix; | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -316,7 +316,7 @@ public class PropertiesLauncher extends Launcher { | |||
| 		for (String path : commaSeparatedPaths.split(",")) { | ||||
| 			path = cleanupPath(path); | ||||
| 			// "" means the user wants root of archive but not current directory | ||||
| 			path = "".equals(path) ? "/" : path; | ||||
| 			path = (path == null || path.isEmpty()) ? "/" : path; | ||||
| 			paths.add(path); | ||||
| 		} | ||||
| 		if (paths.isEmpty()) { | ||||
|  | @ -631,7 +631,7 @@ public class PropertiesLauncher extends Launcher { | |||
| 			} | ||||
| 			EntryFilter filter = new PrefixMatchingArchiveFilter(root); | ||||
| 			List<Archive> archives = asList(parent.getNestedArchives(null, filter)); | ||||
| 			if (("".equals(root) || ".".equals(root)) && !path.endsWith(".jar") | ||||
| 			if ((root == null || root.isEmpty() || ".".equals(root)) && !path.endsWith(".jar") | ||||
| 					&& parent != PropertiesLauncher.this.parent) { | ||||
| 				// You can't find the root with an entry filter so it has to be added | ||||
| 				// explicitly. But don't add the root of the parent archive. | ||||
|  |  | |||
|  | @ -413,7 +413,7 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J | |||
| 	public static void registerUrlProtocolHandler() { | ||||
| 		String handlers = System.getProperty(PROTOCOL_HANDLER, ""); | ||||
| 		System.setProperty(PROTOCOL_HANDLER, | ||||
| 				("".equals(handlers) ? HANDLERS_PACKAGE : handlers + "|" + HANDLERS_PACKAGE)); | ||||
| 				((handlers == null || handlers.isEmpty()) ? HANDLERS_PACKAGE : handlers + "|" + HANDLERS_PACKAGE)); | ||||
| 		resetCachedUrlHandlers(); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue