mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
c998ead188
commit
a3df1d618e
155 changed files with 340 additions and 382 deletions
|
@ -341,7 +341,7 @@ public class Cipher {
|
|||
throw new NoSuchAlgorithmException("Invalid transformation " +
|
||||
"format:" + transformation);
|
||||
}
|
||||
if ((parts[0] == null) || (parts[0].length() == 0)) {
|
||||
if ((parts[0] == null) || (parts[0].isEmpty())) {
|
||||
throw new NoSuchAlgorithmException("Invalid transformation:" +
|
||||
"algorithm not specified-"
|
||||
+ transformation);
|
||||
|
@ -445,10 +445,10 @@ public class Cipher {
|
|||
String alg = parts[0];
|
||||
String mode = parts[1];
|
||||
String pad = parts[2];
|
||||
if ((mode != null) && (mode.length() == 0)) {
|
||||
if ((mode != null) && (mode.isEmpty())) {
|
||||
mode = null;
|
||||
}
|
||||
if ((pad != null) && (pad.length() == 0)) {
|
||||
if ((pad != null) && (pad.isEmpty())) {
|
||||
pad = null;
|
||||
}
|
||||
|
||||
|
@ -634,7 +634,7 @@ public class Cipher {
|
|||
if ((transformation == null) || transformation.isEmpty()) {
|
||||
throw new NoSuchAlgorithmException("Null or empty transformation");
|
||||
}
|
||||
if ((provider == null) || (provider.length() == 0)) {
|
||||
if ((provider == null) || (provider.isEmpty())) {
|
||||
throw new IllegalArgumentException("Missing provider");
|
||||
}
|
||||
Provider p = Security.getProvider(provider);
|
||||
|
|
|
@ -337,7 +337,7 @@ public class SealedObject implements Serializable {
|
|||
if (key == null) {
|
||||
throw new NullPointerException("key is null");
|
||||
}
|
||||
if (provider == null || provider.length() == 0) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public abstract class SSLSocketFactory extends SocketFactory
|
|||
String s = java.security.Security.getProperty(name);
|
||||
if (s != null) {
|
||||
s = s.trim();
|
||||
if (s.length() == 0) {
|
||||
if (s.isEmpty()) {
|
||||
s = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||
|
||||
private void init(String name) {
|
||||
|
||||
if (name == null || name.trim().length() == 0) {
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("invalid empty name");
|
||||
}
|
||||
|
||||
|
|
|
@ -98,13 +98,13 @@ public class ChoiceCallback implements Callback, java.io.Serializable {
|
|||
public ChoiceCallback(String prompt, String[] choices,
|
||||
int defaultChoice, boolean multipleSelectionsAllowed) {
|
||||
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
choices == null || choices.length == 0 ||
|
||||
defaultChoice < 0 || defaultChoice >= choices.length)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
for (int i = 0; i < choices.length; i++) {
|
||||
if (choices[i] == null || choices[i].length() == 0)
|
||||
if (choices[i] == null || choices[i].isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
|
|||
throw new IllegalArgumentException();
|
||||
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (options[i] == null || options[i].length() == 0)
|
||||
if (options[i] == null || options[i].isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
|
|||
public ConfirmationCallback(String prompt, int messageType,
|
||||
int optionType, int defaultOption) {
|
||||
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
messageType < INFORMATION || messageType > ERROR ||
|
||||
optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -357,14 +357,14 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
|
|||
public ConfirmationCallback(String prompt, int messageType,
|
||||
String[] options, int defaultOption) {
|
||||
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
messageType < INFORMATION || messageType > ERROR ||
|
||||
options == null || options.length == 0 ||
|
||||
defaultOption < 0 || defaultOption >= options.length)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (options[i] == null || options[i].length() == 0)
|
||||
if (options[i] == null || options[i].isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class NameCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code prompt} has a length of 0.
|
||||
*/
|
||||
public NameCallback(String prompt) {
|
||||
if (prompt == null || prompt.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ public class NameCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code defaultName} has a length of 0.
|
||||
*/
|
||||
public NameCallback(String prompt, String defaultName) {
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
defaultName == null || defaultName.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
defaultName == null || defaultName.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.prompt = prompt;
|
||||
|
|
|
@ -67,7 +67,7 @@ public class PasswordCallback implements Callback, java.io.Serializable {
|
|||
* if {@code prompt} has a length of 0.
|
||||
*/
|
||||
public PasswordCallback(String prompt, boolean echoOn) {
|
||||
if (prompt == null || prompt.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.prompt = prompt;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code prompt} has a length of 0.
|
||||
*/
|
||||
public TextInputCallback(String prompt) {
|
||||
if (prompt == null || prompt.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ public class TextInputCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code defaultText} has a length of 0.
|
||||
*/
|
||||
public TextInputCallback(String prompt, String defaultText) {
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
defaultText == null || defaultText.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
defaultText == null || defaultText.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.prompt = prompt;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TextOutputCallback implements Callback, java.io.Serializable {
|
|||
public TextOutputCallback(int messageType, String message) {
|
||||
if ((messageType != INFORMATION &&
|
||||
messageType != WARNING && messageType != ERROR) ||
|
||||
message == null || message.length() == 0)
|
||||
message == null || message.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.messageType = messageType;
|
||||
|
|
|
@ -75,7 +75,7 @@ public class AppConfigurationEntry {
|
|||
LoginModuleControlFlag controlFlag,
|
||||
Map<String,?> options)
|
||||
{
|
||||
if (loginModuleName == null || loginModuleName.length() == 0 ||
|
||||
if (loginModuleName == null || loginModuleName.isEmpty() ||
|
||||
(controlFlag != LoginModuleControlFlag.REQUIRED &&
|
||||
controlFlag != LoginModuleControlFlag.REQUISITE &&
|
||||
controlFlag != LoginModuleControlFlag.SUFFICIENT &&
|
||||
|
|
|
@ -418,7 +418,7 @@ public abstract class Configuration {
|
|||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
||||
|
||||
Objects.requireNonNull(type, "null type name");
|
||||
if (provider == null || provider.length() == 0) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ public class LoginContext {
|
|||
public CallbackHandler run() throws Exception {
|
||||
String defaultHandler = java.security.Security.getProperty
|
||||
(DEFAULT_HANDLER);
|
||||
if (defaultHandler == null || defaultHandler.length() == 0)
|
||||
if (defaultHandler == null || defaultHandler.isEmpty())
|
||||
return null;
|
||||
Class<? extends CallbackHandler> c = Class.forName(
|
||||
defaultHandler, true,
|
||||
|
|
|
@ -210,7 +210,7 @@ public abstract class X509Certificate extends Certificate {
|
|||
* under JDK1.1.
|
||||
*/
|
||||
String className = X509Provider;
|
||||
if (className == null || className.length() == 0) {
|
||||
if (className == null || className.isEmpty()) {
|
||||
// shouldn't happen, but assume corrupted properties file
|
||||
// provide access to sun implementation
|
||||
className = "com.sun.security.cert.internal.x509.X509V1CertImpl";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue