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() - 1
: className.length()); : className.length());
} else { } else {
if (className.length() > 0) { if (!className.isEmpty()) {
className = reverseAbbreviationMap.get(className.substring(0, 1)); className = reverseAbbreviationMap.get(className.substring(0, 1));
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -171,7 +171,7 @@ public abstract class StrLookup<V> {
*/ */
@Override @Override
public String lookup(final String key) { public String lookup(final String key) {
if (key.length() > 0) { if (!key.isEmpty()) {
try { try {
return System.getProperty(key); return System.getProperty(key);
} catch (final SecurityException scex) { } 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 // strip the space off again
duration = duration.substring(1); duration = duration.substring(1);
} }