< prev index next >

src/java.base/share/classes/java/net/URL.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb

@@ -1488,11 +1488,11 @@
         String authority = (String)gf.get("authority", null);
         String file = (String)gf.get("file", null);
         String ref = (String)gf.get("ref", null);
         int hashCode = gf.get("hashCode", -1);
         if (authority == null
-                && ((host != null && host.length() > 0) || port != -1)) {
+                && ((host != null && !host.isEmpty()) || port != -1)) {
             if (host == null)
                 host = "";
             authority = (port == -1) ? host : host + ":" + port;
         }
         tempState = new UrlDeserializedState(protocol, host, port, authority,

@@ -1535,11 +1535,11 @@
         int hashCode = tempState.getHashCode();
 
 
         // Construct authority part
         if (authority == null
-            && ((host != null && host.length() > 0) || port != -1)) {
+            && ((host != null && !host.isEmpty()) || port != -1)) {
             if (host == null)
                 host = "";
             authority = (port == -1) ? host : host + ":" + port;
 
             // Handle hosts with userInfo in them

@@ -1691,21 +1691,21 @@
 
     String reconstituteUrlString() {
 
         // pre-compute length of StringBuffer
         int len = protocol.length() + 1;
-        if (authority != null && authority.length() > 0)
+        if (authority != null && !authority.isEmpty())
             len += 2 + authority.length();
         if (file != null) {
             len += file.length();
         }
         if (ref != null)
             len += 1 + ref.length();
         StringBuilder result = new StringBuilder(len);
         result.append(protocol);
         result.append(":");
-        if (authority != null && authority.length() > 0) {
+        if (authority != null && !authority.isEmpty()) {
             result.append("//");
             result.append(authority);
         }
         if (file != null) {
             result.append(file);
< prev index next >