diff --git a/spring-core/src/main/java/org/springframework/cglib/core/TypeUtils.java b/spring-core/src/main/java/org/springframework/cglib/core/TypeUtils.java index de0f693146..71158205c5 100644 --- a/spring-core/src/main/java/org/springframework/cglib/core/TypeUtils.java +++ b/spring-core/src/main/java/org/springframework/cglib/core/TypeUtils.java @@ -97,7 +97,7 @@ public class TypeUtils { } public static String upperFirst(String s) { - if (s == null || s.length() == 0) { + if (s == null || s.isEmpty()) { return s; } return Character.toUpperCase(s.charAt(0)) + s.substring(1); diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java index 0175c0b1c3..c658352846 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 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. @@ -153,7 +153,7 @@ public final class BindMarkersFactoryResolver { builder.append(ch); } } - if (builder.length() == 0) { + if (builder.isEmpty()) { return ""; } return "_" + builder.toString(); diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index 32bc0eda0a..82b2004609 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -877,7 +877,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable { @Override @Nullable public PathComponent build() { - if (this.path.length() == 0) { + if (this.path.isEmpty()) { return null; } String sanitized = getSanitizedPath(this.path); diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/CaptureVariablePathElement.java b/spring-web/src/main/java/org/springframework/web/util/pattern/CaptureVariablePathElement.java index b3002295a9..8acf0c7907 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/CaptureVariablePathElement.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/CaptureVariablePathElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -73,7 +73,7 @@ class CaptureVariablePathElement extends PathElement { return false; } String candidateCapture = matchingContext.pathElementValue(pathIndex); - if (candidateCapture.length() == 0) { + if (candidateCapture.isEmpty()) { return false; } diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/WildcardPathElement.java b/spring-web/src/main/java/org/springframework/web/util/pattern/WildcardPathElement.java index 0fa2be98b9..61c584f9c4 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/WildcardPathElement.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/WildcardPathElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -66,7 +66,7 @@ class WildcardPathElement extends PathElement { } else { return (matchingContext.isMatchOptionalTrailingSeparator() && // if optional slash is on... - segmentData != null && segmentData.length() > 0 && // and there is at least one character to match the *... + segmentData != null && !segmentData.isEmpty() && // and there is at least one character to match the *... (pathIndex + 1) == matchingContext.pathLength && // and the next path element is the end of the candidate... matchingContext.isSeparator(pathIndex)); // and the final element is a separator } @@ -74,7 +74,7 @@ class WildcardPathElement extends PathElement { } else { // Within a path (e.g. /aa/*/bb) there must be at least one character to match the wildcard - if (segmentData == null || segmentData.length() == 0) { + if (segmentData == null || segmentData.isEmpty()) { return false; } return (this.next != null && this.next.matches(pathIndex, matchingContext)); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java index d3062c94c7..49c9258dbb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -323,7 +323,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware { StringBuilder qs = new StringBuilder(); for (Param param : params) { if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) { - if (includeQueryStringDelimiter && qs.length() == 0) { + if (includeQueryStringDelimiter && qs.isEmpty()) { qs.append('?'); } else {