Use String#isEmpty()
Closes gh-1335
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -28,7 +28,7 @@ final class StringToCharacterConverter implements Converter<String, Character> {
|
||||
|
||||
@Override
|
||||
public Character convert(String source) {
|
||||
if (source.length() == 0) {
|
||||
if (source.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (source.length() > 1) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -45,7 +45,7 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
|
||||
|
||||
@Override
|
||||
public T convert(String source) {
|
||||
if (source.length() == 0) {
|
||||
if (source.isEmpty()) {
|
||||
// It's an empty enum identifier: reset the enum value to null.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -56,7 +56,7 @@ final class StringToNumberConverterFactory implements ConverterFactory<String, N
|
||||
|
||||
@Override
|
||||
public T convert(String source) {
|
||||
if (source.length() == 0) {
|
||||
if (source.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return NumberUtils.parseNumber(source, this.targetType);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -809,7 +809,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher pathMatcher) {
|
||||
this.subPattern = subPattern;
|
||||
this.pathMatcher = pathMatcher;
|
||||
this.rootPath = (rootPath.length() == 0 || rootPath.endsWith("/") ? rootPath : rootPath + "/");
|
||||
this.rootPath = (rootPath.isEmpty() || rootPath.endsWith("/") ? rootPath : rootPath + "/");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -120,7 +120,7 @@ public abstract class Base64Utils {
|
||||
if (src == null) {
|
||||
return null;
|
||||
}
|
||||
if (src.length() == 0) {
|
||||
if (src.isEmpty()) {
|
||||
return new byte[0];
|
||||
}
|
||||
return decode(src.getBytes(DEFAULT_CHARSET));
|
||||
|
||||
@@ -180,7 +180,7 @@ public abstract class MimeTypeUtils {
|
||||
|
||||
int index = mimeType.indexOf(';');
|
||||
String fullType = (index >= 0 ? mimeType.substring(0, index) : mimeType).trim();
|
||||
if (fullType.length() == 0) {
|
||||
if (fullType.isEmpty()) {
|
||||
throw new InvalidMimeTypeException(mimeType, "'mimeType' must not be empty");
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ public abstract class StringUtils {
|
||||
* @param sub string to search for. Return 0 if this is {@code null}.
|
||||
*/
|
||||
public static int countOccurrencesOf(String str, String sub) {
|
||||
if (str == null || sub == null || str.length() == 0 || sub.length() == 0) {
|
||||
if (!hasLength(str) || !hasLength(sub)) {
|
||||
return 0;
|
||||
}
|
||||
int count = 0;
|
||||
@@ -515,7 +515,7 @@ public abstract class StringUtils {
|
||||
}
|
||||
|
||||
private static String changeFirstCharacterCase(String str, boolean capitalize) {
|
||||
if (str == null || str.length() == 0) {
|
||||
if (!hasLength(str)) {
|
||||
return str;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -223,8 +223,8 @@ abstract class AbstractStaxHandler implements ContentHandler, LexicalHandler {
|
||||
protected boolean isNamespaceDeclaration(QName qName) {
|
||||
String prefix = qName.getPrefix();
|
||||
String localPart = qName.getLocalPart();
|
||||
return (XMLConstants.XMLNS_ATTRIBUTE.equals(localPart) && prefix.length() == 0) ||
|
||||
(XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) && localPart.length() != 0);
|
||||
return (XMLConstants.XMLNS_ATTRIBUTE.equals(localPart) && prefix.isEmpty()) ||
|
||||
(XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) && !localPart.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user