replaces 'size() == 0' and 'length() == 0' with 'isEmpty()'

This commit is contained in:
Igor Curdvanovschi 2018-06-20 13:05:02 +03:00
parent 96260205dc
commit 214cc7fd59
7 changed files with 12 additions and 12 deletions

View File

@ -1347,7 +1347,7 @@ public class ClassUtils {
? className.length() - 1
: className.length());
} else {
if (className.length() > 0) {
if (!className.isEmpty()) {
className = reverseAbbreviationMap.get(className.substring(0, 1));
}
}

View File

@ -150,8 +150,8 @@ public class LocaleUtils {
final String country = segments[1];
final String variant = segments[2];
if (isISO639LanguageCode(language) &&
(country.length() == 0 || isISO3166CountryCode(country) || isNumericAreaCode(country)) &&
variant.length() > 0) {
(country.isEmpty() || isISO3166CountryCode(country) || isNumericAreaCode(country)) &&
!variant.isEmpty()) {
return new Locale(language, country, variant);
}
}
@ -227,10 +227,10 @@ public class LocaleUtils {
final List<Locale> list = new ArrayList<>(4);
if (locale != null) {
list.add(locale);
if (locale.getVariant().length() > 0) {
if (!locale.getVariant().isEmpty()) {
list.add(new Locale(locale.getLanguage(), locale.getCountry()));
}
if (locale.getCountry().length() > 0) {
if (!locale.getCountry().isEmpty()) {
list.add(new Locale(locale.getLanguage(), StringUtils.EMPTY));
}
if (!list.contains(defaultLocale)) {
@ -330,7 +330,7 @@ public class LocaleUtils {
final List<Locale> locales = availableLocaleList();
for (final Locale locale : locales) {
if (languageCode.equals(locale.getLanguage()) &&
locale.getCountry().length() != 0 &&
!locale.getCountry().isEmpty() &&
locale.getVariant().isEmpty()) {
countries.add(locale);
}

View File

@ -170,7 +170,7 @@ public class DiffResult implements Iterable<Diff<?>> {
* @return a {@code String} description of the differences.
*/
public String toString(final ToStringStyle style) {
if (diffs.size() == 0) {
if (diffs.isEmpty()) {
return OBJECTS_SAME_STRING;
}

View File

@ -130,7 +130,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
buffer.append(baseMessage);
}
if (contextValues.size() > 0) {
if (!contextValues.isEmpty()) {
if (buffer.length() > 0) {
buffer.append('\n');
}

View File

@ -526,7 +526,7 @@ public class NumberUtils {
case 'L' :
if (dec == null
&& exp == null
&& (numeric.length() > 0 && numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
&& (!numeric.isEmpty() && numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
try {
return createLong(numeric);
} catch (final NumberFormatException nfe) { // NOPMD
@ -661,7 +661,7 @@ public class NumberUtils {
return false;
}
}
return str.length() > 0;
return !str.isEmpty();
}
//-----------------------------------------------------------------------

View File

@ -171,7 +171,7 @@ public abstract class StrLookup<V> {
*/
@Override
public String lookup(final String key) {
if (key.length() > 0) {
if (!key.isEmpty()) {
try {
return System.getProperty(key);
} catch (final SecurityException scex) {

View File

@ -195,7 +195,7 @@ public class DurationFormatUtils {
}
}
}
if (duration.length() != 0) {
if (!duration.isEmpty()) {
// strip the space off again
duration = duration.substring(1);
}