You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by gg...@apache.org on 2023/06/23 18:02:52 UTC
[juneau] 03/04: [juneau-marshall] Reuse String#isEmpty() instead of custom length check
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
commit 806c26521f72e75ff42f0049a54bfec42c202c79
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Fri Jun 23 14:02:08 2023 -0400
[juneau-marshall] Reuse String#isEmpty() instead of custom length check
---
.../src/main/java/org/apache/juneau/UriResolver.java | 2 +-
.../src/main/java/org/apache/juneau/json/JsonParserSession.java | 2 +-
.../src/main/java/org/apache/juneau/objecttools/ObjectRest.java | 6 +++---
.../src/main/java/org/apache/juneau/xml/XmlUtils.java | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriResolver.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriResolver.java
index e3681cacd..214031a88 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriResolver.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriResolver.java
@@ -263,7 +263,7 @@ public class UriResolver {
}
private static boolean isSpecialUri(String s) {
- if (s == null || s.length() == 0)
+ if (s == null || s.isEmpty())
return false;
char c = s.charAt(0);
if (c != 's' && c != 'c' && c != 'r')
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
index 6bd757930..0bc7b3b9c 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
@@ -407,7 +407,7 @@ public final class JsonParserSession extends ReaderParserSession {
// Lax allows blank strings to represent 0.
// Strict does not allow blank strings.
- if (s.length() == 0)
+ if (s.isEmpty())
throw new ParseException(this, "Invalid JSON number: ''{0}''", s);
// Need to weed out octal and hexadecimal formats: 0123,-0123,0x123,-0x123.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
index c4b9e7b39..d7582b1dc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
@@ -771,7 +771,7 @@ public final class ObjectRest {
String childKey = (i == -1 ? url : url.substring(i + 1));
if (method == PUT) {
- if (url.length() == 0) {
+ if (url.isEmpty()) {
if (rootLocked)
throw new ObjectRestException(HTTP_FORBIDDEN, "Cannot overwrite root object");
Object o = root.o;
@@ -809,7 +809,7 @@ public final class ObjectRest {
if (method == POST) {
// Handle POST to root special
- if (url.length() == 0) {
+ if (url.isEmpty()) {
ClassMeta cm = root.cm;
Object o = root.o;
if (cm.isCollection()) {
@@ -853,7 +853,7 @@ public final class ObjectRest {
}
if (method == DELETE) {
- if (url.length() == 0) {
+ if (url.isEmpty()) {
if (rootLocked)
throw new ObjectRestException(HTTP_FORBIDDEN, "Cannot overwrite root object");
Object o = root.o;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
index 8b2c8c774..e75e1099b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
@@ -388,7 +388,7 @@ public final class XmlUtils {
public static final String decode(String value, StringBuilder sb) {
if (value == null)
return null;
- if (value.length() == 0 || value.indexOf('_') == -1)
+ if (value.isEmpty() || value.indexOf('_') == -1)
return value;
if (sb == null)
sb = new StringBuilder(value.length());