8215281: Use String.isEmpty() when applicable in java.base

Reviewed-by: dfuchs, alanb
This commit is contained in:
Claes Redestad 2018-12-13 15:31:05 +01:00
parent c998ead188
commit a3df1d618e
155 changed files with 340 additions and 382 deletions

View file

@ -372,7 +372,7 @@ public abstract class ZoneId implements Serializable {
public static ZoneId ofOffset(String prefix, ZoneOffset offset) {
Objects.requireNonNull(prefix, "prefix");
Objects.requireNonNull(offset, "offset");
if (prefix.length() == 0) {
if (prefix.isEmpty()) {
return offset;
}

View file

@ -1439,7 +1439,7 @@ public final class DateTimeFormatterBuilder {
*/
public DateTimeFormatterBuilder appendLiteral(String literal) {
Objects.requireNonNull(literal, "literal");
if (literal.length() > 0) {
if (!literal.isEmpty()) {
if (literal.length() == 1) {
appendInternal(new CharLiteralPrinterParser(literal.charAt(0)));
} else {
@ -1832,7 +1832,7 @@ public final class DateTimeFormatterBuilder {
throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern);
}
String str = pattern.substring(start + 1, pos);
if (str.length() == 0) {
if (str.isEmpty()) {
appendLiteral('\'');
} else {
appendLiteral(str.replace("''", "'"));
@ -4332,7 +4332,7 @@ public final class DateTimeFormatterBuilder {
this.key = k;
this.value = v;
this.child = child;
if (k.length() == 0){
if (k.isEmpty()) {
c0 = 0xffff;
} else {
c0 = key.charAt(0);