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 @@ private static String getCanonicalName(String className) {
? 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 @@ private static Locale parseLocale(final String str) {
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 static List<Locale> localeLookupList(final Locale locale, final Locale de
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 static List<Locale> countriesByLanguage(final String languageCode) {
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 String toString() {
* @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 String getFormattedExceptionMessage(final String baseMessage){
buffer.append(baseMessage);
}
if (contextValues.size() > 0) {
if (!contextValues.isEmpty()) {
if (buffer.length() > 0) {
buffer.append('\n');
}

View File

@ -526,7 +526,7 @@ public static Number createNumber(final String str) {
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 @@ private static boolean isAllZeros(final String str) {
return false;
}
}
return str.length() > 0;
return !str.isEmpty();
}
//-----------------------------------------------------------------------

View File

@ -171,7 +171,7 @@ private static class SystemPropertiesStrLookup extends StrLookup<String> {
*/
@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 static String formatDurationWords(
}
}
}
if (duration.length() != 0) {
if (!duration.isEmpty()) {
// strip the space off again
duration = duration.substring(1);
}