< prev index next >

src/java.prefs/share/classes/java/util/prefs/AbstractPreferences.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad

@@ -201,20 +201,20 @@
      *          ({@code '/'}),  or {@code parent} is {@code null} and
      *          name isn't {@code ""}.
      */
     protected AbstractPreferences(AbstractPreferences parent, String name) {
         if (parent==null) {
-            if (!name.equals(""))
+            if (!name.isEmpty())
                 throw new IllegalArgumentException("Root name '"+name+
                                                    "' must be \"\"");
             this.absolutePath = "/";
             root = this;
         } else {
             if (name.indexOf('/') != -1)
                 throw new IllegalArgumentException("Name '" + name +
                                                  "' contains '/'");
-            if (name.equals(""))
+            if (name.isEmpty())
               throw new IllegalArgumentException("Illegal name: empty string");
 
             root = parent.root;
             absolutePath = (parent==root ? "/" + name
                                          : parent.absolutePath() + "/" + name);

@@ -846,11 +846,11 @@
      */
     public Preferences node(String path) {
         synchronized(lock) {
             if (removed)
                 throw new IllegalStateException("Node has been removed.");
-            if (path.equals(""))
+            if (path.isEmpty())
                 return this;
             if (path.equals("/"))
                 return root;
             if (path.charAt(0) != '/')
                 return node(new StringTokenizer(path, "/", true));

@@ -909,11 +909,11 @@
      */
     public boolean nodeExists(String path)
         throws BackingStoreException
     {
         synchronized(lock) {
-            if (path.equals(""))
+            if (path.isEmpty())
                 return !removed;
             if (removed)
                 throw new IllegalStateException("Node has been removed.");
             if (path.equals("/"))
                 return true;
< prev index next >