]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use String.isEmpty() (#10045)
authorAhmed Ashour <asashour@yahoo.com>
Thu, 21 Sep 2017 08:51:51 +0000 (10:51 +0200)
committerHenri Sara <henri.sara@gmail.com>
Thu, 21 Sep 2017 08:51:51 +0000 (11:51 +0300)
64 files changed:
client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java
client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java
client/src/main/java/com/vaadin/client/ResourceLoader.java
client/src/main/java/com/vaadin/client/VErrorMessage.java
client/src/main/java/com/vaadin/client/WidgetUtil.java
client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java
client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java
client/src/main/java/com/vaadin/client/ui/VAccordion.java
client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java
client/src/main/java/com/vaadin/client/ui/VComboBox.java
client/src/main/java/com/vaadin/client/ui/VLink.java
client/src/main/java/com/vaadin/client/ui/VNotification.java
client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java
client/src/main/java/com/vaadin/client/ui/VUpload.java
client/src/main/java/com/vaadin/client/ui/VWindow.java
client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java
client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java
client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java
compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java
compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java
server/src/main/java/com/vaadin/server/AbstractErrorMessage.java
server/src/main/java/com/vaadin/server/BootstrapHandler.java
server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java
server/src/main/java/com/vaadin/server/Page.java
server/src/main/java/com/vaadin/server/SizeWithUnit.java
server/src/main/java/com/vaadin/server/ThemeResource.java
server/src/main/java/com/vaadin/server/VaadinServlet.java
server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
server/src/main/java/com/vaadin/ui/ComboBox.java
server/src/main/java/com/vaadin/ui/CustomLayout.java
server/src/main/java/com/vaadin/ui/MenuBar.java
server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
server/src/main/java/com/vaadin/ui/declarative/DesignContext.java
server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java
server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java
server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java
shared/src/main/java/com/vaadin/shared/util/SharedUtil.java
uitest/src/main/java/com/vaadin/tests/Parameters.java
uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java
uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java
uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java
uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java
uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java
uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java
uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java

index 864582546bdb0e853880fbb1adb517eeef8b0107..4057c531d67d30aa27f563d10fe7849d5585a903 100644 (file)
@@ -143,7 +143,7 @@ public class ReportUsage {
         appendUserAgentProperty(extra, "os.name");
         appendUserAgentProperty(extra, "os.version");
 
-        if (extra.length() > 0) {
+        if (extra.length() != 0) {
             userAgent += " (" + extra.toString() + ")";
         }
 
@@ -154,7 +154,7 @@ public class ReportUsage {
             String propName) {
         String propValue = System.getProperty(propName);
         if (propValue != null) {
-            if (sb.length() > 0) {
+            if (sb.length() != 0) {
                 sb.append(';').append(' ');
             }
             sb.append(propName);
index f0a6e7057a9009c77ec605356e9b3a91978f3147..05449f11262b5aa88233f9286a6eec007c04c640 100644 (file)
@@ -331,7 +331,7 @@ public class JavaScriptConnectorHelper {
     }
 
     private ServerConnector getConnector(String connectorId) {
-        if (connectorId == null || connectorId.length() == 0) {
+        if (connectorId == null || connectorId.isEmpty()) {
             return connector;
         }
 
@@ -364,7 +364,7 @@ public class JavaScriptConnectorHelper {
             // TODO Resolve conflicts using argument count and types
             String interfaceList = "";
             for (String iface : interfaces) {
-                if (interfaceList.length() != 0) {
+                if (!interfaceList.isEmpty()) {
                     interfaceList += ", ";
                 }
                 interfaceList += getJsInterfaceName(iface);
index 53967a74f7a2ad79955d50728ad7d2c69d923c69..12922dca00a62a40b9bf01669fc7d6e23617258e 100644 (file)
@@ -141,7 +141,7 @@ public class ResourceLoader {
         for (int i = 0; i < scripts.getLength(); i++) {
             ScriptElement element = ScriptElement.as(scripts.getItem(i));
             String src = element.getSrc();
-            if (src != null && src.length() != 0) {
+            if (src != null && !src.isEmpty()) {
                 loadedResources.add(src);
             }
         }
@@ -152,11 +152,11 @@ public class ResourceLoader {
             String rel = linkElement.getRel();
             String href = linkElement.getHref();
             if ("stylesheet".equalsIgnoreCase(rel) && href != null
-                    && href.length() != 0) {
+                    && !href.isEmpty()) {
                 loadedResources.add(href);
             }
             if ("import".equalsIgnoreCase(rel) && href != null
-                    && href.length() != 0) {
+                    && !href.isEmpty()) {
                 loadedResources.add(href);
             }
         }
index b87704f3e024d5f8f83c04b191769878f06a9db6..0baa1baff1864e3947d15d4b314792bea43aa3c8 100644 (file)
@@ -49,7 +49,7 @@ public class VErrorMessage extends FlowPanel {
 
     public void updateMessage(String htmlErrorMessage) {
         clear();
-        if (htmlErrorMessage == null || htmlErrorMessage.length() == 0) {
+        if (htmlErrorMessage == null || htmlErrorMessage.isEmpty()) {
             add(new HTML(" "));
         } else {
             // pre-formatted on the server as div per child
index 3390881b726a9e7426233c3f7d30c971e24ef21c..d24a1d53a59be5e6546024f599659a6307b44fe4 100644 (file)
@@ -934,7 +934,7 @@ public class WidgetUtil {
     public static void forceWebkitRedraw(Element element) {
         Style style = element.getStyle();
         String s = style.getProperty("webkitTransform");
-        if (s == null || s.length() == 0) {
+        if (s == null || s.isEmpty()) {
             style.setProperty("webkitTransform", "scale(1)");
         } else {
             style.setProperty("webkitTransform", "");
index f01c693c4cdb957441382b931992500d74d54152..ddab95d2c9b986bbb66e1efd9a50b9db4783e9e2 100644 (file)
@@ -42,9 +42,9 @@ public class SelectorPredicate {
     }
 
     /**
-     * Generate a list of predicates from a single predicate string
+     * Generates a list of predicates from a single predicate string.
      *
-     * @param str
+     * @param path
      *            a comma separated string of predicates
      * @return a List of Predicate objects
      */
@@ -52,7 +52,7 @@ public class SelectorPredicate {
         List<SelectorPredicate> predicates = new ArrayList<>();
 
         String predicateStr = extractPredicateString(path);
-        if (null == predicateStr || predicateStr.length() == 0) {
+        if (null == predicateStr || predicateStr.isEmpty()) {
             return predicates;
         }
 
index c7abe8c15f961d35e1cd5128ee727f0e3660847c..77e1ee0a09448fab7783982540c75939400f94b0 100644 (file)
@@ -424,7 +424,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy {
             ComponentConnector root, Element actualRoot) {
         String[] pathComponents = path.split(SUBPART_SEPARATOR);
         List<ComponentConnector> connectors;
-        if (pathComponents[0].length() > 0) {
+        if (!pathComponents[0].isEmpty()) {
             connectors = findConnectorsByPath(pathComponents[0],
                     Arrays.asList(root));
         } else {
index ae24ed850fca703dbce68ad3c9b15a6acc2660f9..44a60b9fd5c2ec8cf07f1c32d8092f01a0606d1d 100644 (file)
@@ -273,7 +273,7 @@ public class GridDropTargetConnector extends DropTargetExtensionConnector {
                 if ("thead".equalsIgnoreCase(parentTagName)) {
                     // for empty grid or ON_TOP mode, drop as last row,
                     // otherwise as above first visible row
-                    if (visibleRowRange.length() == 0
+                    if (visibleRowRange.isEmpty()
                             || getState().dropMode == DropMode.ON_TOP) {
                         return tableWrapper;
                     } else {
@@ -283,7 +283,7 @@ public class GridDropTargetConnector extends DropTargetExtensionConnector {
                 } else if ("tfoot".equalsIgnoreCase(parentTagName)) {
                     // for empty grid or ON_TOP mode, drop as last row,
                     // otherwise as below last visible row
-                    if (visibleRowRange.length() == 0
+                    if (visibleRowRange.isEmpty()
                             || getState().dropMode == DropMode.ON_TOP) {
                         return tableWrapper;
                     } else {
@@ -299,7 +299,7 @@ public class GridDropTargetConnector extends DropTargetExtensionConnector {
         // the drag is on top of the tablewrapper
         // if no rows in grid, or if the drop mode is ON_TOP, then there is no
         // target row for the drop
-        if (visibleRowRange.length() == 0
+        if (visibleRowRange.isEmpty()
                 || getState().dropMode == DropMode.ON_TOP) {
             return tableWrapper;
         } else { // if dragged under the last row to empty space, drop target
index 73f48639f3fd31186ba66fdafa55cc03ce8be6c7..16c16935d0c998f775f74232d4a6b16434e9ef98 100644 (file)
@@ -376,13 +376,13 @@ public class VAccordion extends VTabsheetBase {
          * Updates a tabs stylename from the child UIDL
          *
          * @param uidl
-         *            The child uidl of the tab
+         *            The child UIDL of the tab
          */
         private void updateTabStyleName(String newStyleName) {
-            if (newStyleName != null && newStyleName.length() != 0) {
+            if (newStyleName != null && !newStyleName.isEmpty()) {
                 if (!newStyleName.equals(styleName)) {
                     // If we have a new style name
-                    if (styleName != null && styleName.length() != 0) {
+                    if (styleName != null && !styleName.isEmpty()) {
                         // Remove old style name if present
                         removeStyleDependentName(styleName);
                     }
index 427c4011a524aa811c6250736086a9783d5064de..a957690526d5443bba8eda813f06f4fd4bdbc605 100644 (file)
@@ -124,7 +124,7 @@ public class VCheckBoxGroup extends FocusableFlowPanelComposite
         }
 
         String iconUrl = item.getString(ListingJsonConstants.JSONKEY_ITEM_ICON);
-        if (iconUrl != null && iconUrl.length() != 0) {
+        if (iconUrl != null && !iconUrl.isEmpty()) {
             Icon icon = client.getIcon(iconUrl);
             itemHtml = icon.getElement().getString() + itemHtml;
         }
index ebb993702c6d47c3920ed9ecfac3737ddff07405..c872026ac7f8b865b1515c9c7f78c2a1932284b9 100644 (file)
@@ -1287,7 +1287,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
             String height = getElement().getStyle().getHeight();
             String preferredHeight = getPreferredHeight(pageLength);
 
-            return !(height == null || height.length() == 0
+            return !(height == null || height.isEmpty()
                     || height.equals(preferredHeight));
         }
 
@@ -2038,7 +2038,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
         if (selectedItemIcon != null) {
             panel.remove(selectedItemIcon);
         }
-        if (iconUri == null || iconUri.length() == 0) {
+        if (iconUri == null || iconUri.isEmpty()) {
             if (selectedItemIcon != null) {
                 selectedItemIcon = null;
                 afterSelectedItemIconChange();
@@ -2422,7 +2422,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
         for (ComboBoxSuggestion suggestion : currentSuggestions) {
             // Collect captions so we can calculate minimum width for
             // textarea
-            if (captions.length() > 0) {
+            if (!captions.isEmpty()) {
                 captions += "|";
             }
             captions += WidgetUtil
@@ -2658,7 +2658,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
     @Override
     public void setWidth(String width) {
         super.setWidth(width);
-        if (width.length() != 0) {
+        if (!width.isEmpty()) {
             tb.setWidth("100%");
         }
     }
index ede020e572af064df66f32d5589abbd73b39ff99..84aac0f17e3f20e951fd451d058bafde0eae1120 100644 (file)
@@ -98,15 +98,15 @@ public class VLink extends HTML implements ClickHandler, HasEnabled {
             }
 
             if (targetWidth > 0) {
-                features += (features.length() > 0 ? "," : "") + "width="
+                features += (features.isEmpty() ? "" : ",") + "width="
                         + targetWidth;
             }
             if (targetHeight > 0) {
-                features += (features.length() > 0 ? "," : "") + "height="
+                features += (features.isEmpty() ? "" : ",") + "height="
                         + targetHeight;
             }
 
-            if (features.length() > 0) {
+            if (!features.isEmpty()) {
                 // if 'special features' are set, use window.open(), unless
                 // a modifier key is held (ctrl to open in new tab etc)
                 Event e = DOM.eventGetCurrentEvent();
index e5358a3db79bf4aa304e083068572eb185939069..0eaee0102c0fb99c9aab927d56c594433cdcf048 100644 (file)
@@ -247,7 +247,7 @@ public class VNotification extends VOverlay {
             removeStyleDependentName(temporaryStyle);
             temporaryStyle = null;
         }
-        if (style != null && style.length() > 0) {
+        if (style != null && !style.isEmpty()) {
             temporaryStyle = style;
             addStyleName(style);
             addStyleDependentName(style);
@@ -635,7 +635,7 @@ public class VNotification extends VOverlay {
             html.append("</p>");
         }
 
-        if (html.length() > 0) {
+        if (html.length() != 0) {
 
             // Add error description
             if (details != null) {
index 15b0d6f0437d7b83bff225d3d1df6b4dca99d214..4f0bed52ed2a4ee2515927248b2ebf3cf2566723 100644 (file)
@@ -143,7 +143,7 @@ public class VRadioButtonGroup extends FocusableFlowPanelComposite
         }
 
         String iconUrl = item.getString(ListingJsonConstants.JSONKEY_ITEM_ICON);
-        if (iconUrl != null && iconUrl.length() != 0) {
+        if (iconUrl != null && !iconUrl.isEmpty()) {
             Icon icon = client.getIcon(iconUrl);
             itemHtml = icon.getElement().getString() + itemHtml;
         }
index d25508d29a027b761aea14f5502da7fc2b6169ce..dd4c2954927f5ad2bfad9929f5a3a39fd7e9c021 100644 (file)
@@ -332,7 +332,7 @@ public class VUpload extends SimplePanel {
             VConsole.log("Submit cancelled (disabled or already submitted)");
             return;
         }
-        if (fu.getFilename().length() == 0) {
+        if (fu.getFilename().isEmpty()) {
             VConsole.log("Submitting empty selection (no file)");
         }
         // flush possibly pending variable changes, so they will be handled
index c6d817587b643e952c16f726f617b2bf4c596cfd..9e4aad0d2c03aa5496d45a86b7279d719754951c 100644 (file)
@@ -1204,7 +1204,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
         // Override PopupPanel which sets the width to the contents
         getElement().getStyle().setProperty("width", width);
         // Update v-has-width in case undefined window is resized
-        setStyleName("v-has-width", width != null && width.length() > 0);
+        setStyleName("v-has-width", width != null && !width.isEmpty());
     }
 
     @Override
@@ -1212,7 +1212,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
         // Override PopupPanel which sets the height to the contents
         getElement().getStyle().setProperty("height", height);
         // Update v-has-height in case undefined window is resized
-        setStyleName("v-has-height", height != null && height.length() > 0);
+        setStyleName("v-has-height", height != null && !height.isEmpty());
     }
 
     private void onDragEvent(Event event) {
index 815509c44b9d72172e477eaf37fe13c69f312626..c837570c85d8f00cd7c4bfbd3272bdc4672a5dda 100644 (file)
@@ -615,7 +615,7 @@ public class LayoutDependencyTree {
     }
 
     private static String getSizeDefinition(String size) {
-        if (size == null || size.length() == 0) {
+        if (size == null || size.isEmpty()) {
             return "undefined";
         } else if (size.endsWith("%")) {
             return "relative";
index 4e28fb63490d389a153a6b001a7d266aecde88f1..dc8d30e5175b4a70209620545d3c8a60643c2813 100644 (file)
@@ -252,7 +252,7 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
                 childStyle.setPosition(Position.ABSOLUTE);
 
                 Style wrapperStyle = contentElement.getStyle();
-                if (window.getElement().getStyle().getWidth().length() == 0
+                if (window.getElement().getStyle().getWidth().isEmpty()
                         && !content.isRelativeWidth()) {
                     /*
                      * Need to lock width to make undefined width work even with
index 8a84208ea81cee957527d560677bd0747601e242..1473af44ae3ce5f01986dd688375b18c9625e517 100644 (file)
@@ -56,7 +56,7 @@ public class ApplicationConnectionURLGenerationTest {
                     SharedUtil.addGetParameters(URIS[i], "a=b&c=d"));
 
             // Fragments
-            if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) {
+            if (!URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].isEmpty()) {
                 assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i], SharedUtil
                         .addGetParameters(URIS[i] + "#fragment", "a=b&c=d"));
 
index 64cc713e204ed9eacef1eb40a017dd50f71e4456..b78ad3928be63ce06f2f6fb963341b9ba5663c26 100644 (file)
@@ -1339,7 +1339,7 @@ public class VFilterSelect extends Composite
             String height = getElement().getStyle().getHeight();
             String preferredHeight = getPreferredHeight(pageLength);
 
-            return !(height == null || height.length() == 0
+            return !(height == null || height.isEmpty()
                     || height.equals(preferredHeight));
         }
 
@@ -1916,7 +1916,7 @@ public class VFilterSelect extends Composite
      */
     public void setSelectedItemIcon(String iconUri) {
 
-        if (iconUri == null || iconUri.length() == 0) {
+        if (iconUri == null || iconUri.isEmpty()) {
             if (selectedItemIcon != null) {
                 panel.remove(selectedItemIcon);
                 selectedItemIcon = null;
@@ -2302,7 +2302,7 @@ public class VFilterSelect extends Composite
         for (FilterSelectSuggestion suggestion : currentSuggestions) {
             // Collect captions so we can calculate minimum width for
             // textarea
-            if (captions.length() > 0) {
+            if (!captions.isEmpty()) {
                 captions += "|";
             }
             captions += WidgetUtil
@@ -2549,7 +2549,7 @@ public class VFilterSelect extends Composite
     @Override
     public void setWidth(String width) {
         super.setWidth(width);
-        if (width.length() != 0) {
+        if (!width.isEmpty()) {
             tb.setWidth("100%");
         }
     }
index ee9048d4c2f21abaab94f36057e73236a50df7f7..2140610559b1c16157b76b7169cc8e2bf691ff3c 100644 (file)
@@ -143,7 +143,7 @@ public class VOptionGroup extends VOptionGroupBase
             }
 
             String iconUrl = opUidl.getStringAttribute("icon");
-            if (iconUrl != null && iconUrl.length() != 0) {
+            if (iconUrl != null && !iconUrl.isEmpty()) {
                 Icon icon = client.getIcon(iconUrl);
                 itemHtml = icon.getElement().getString() + itemHtml;
             }
@@ -162,7 +162,7 @@ public class VOptionGroup extends VOptionGroupBase
                     op = new RadioButton(paintableId);
                     op.setStyleName("v-radiobutton");
                 }
-                if (iconUrl != null && iconUrl.length() != 0) {
+                if (iconUrl != null && !iconUrl.isEmpty()) {
                     WidgetUtil.sinkOnloadForImages(op.getElement());
                     op.addHandler(iconLoadHandler, LoadEvent.getType());
                 }
index 2e20abe4a0f915b2a6527ac708f1f548a6133cfd..cf8d53d42a8016ac55747f219764e9b6e258eaeb 100644 (file)
@@ -7256,8 +7256,8 @@ public class VScrollTable extends FlowPanel
 
     @Override
     public void setHeight(String height) {
-        if (height.length() == 0
-                && getElement().getStyle().getHeight().length() != 0) {
+        if (height.isEmpty()
+                && !getElement().getStyle().getHeight().isEmpty()) {
             /*
              * Changing from defined to undefined size -> should do a size init
              * to take page length into account again
index 4969f19933d8c0fd42a8328aeff9bf2b767243af..1a93e04e1e5b90523097617cf6d13de6da1a03b3 100644 (file)
@@ -314,7 +314,7 @@ public class VUpload extends SimplePanel {
             VConsole.log("Submit cancelled (disabled or already submitted)");
             return;
         }
-        if (fu.getFilename().length() == 0) {
+        if (fu.getFilename().isEmpty()) {
             VConsole.log("Submitting empty selection (no file)");
         }
         // flush possibly pending variable changes, so they will be handled
index 5695365db8f156184d0f9b126efc18374b0e83d2..65b49b843421bcde2bc1ec0a105d9be70b84dd51 100644 (file)
@@ -91,7 +91,7 @@ public class DateCellDayEvent extends FocusableHTML
         weekGrid = parent;
 
         Style s = getElement().getStyle();
-        if (event.getStyleName().length() > 0) {
+        if (!event.getStyleName().isEmpty()) {
             addStyleDependentName(event.getStyleName());
         }
         s.setPosition(Position.ABSOLUTE);
index f671d7c21d22acb6cc803debada1a952694ee97c..df0d74d3b513e95657d26d49f663cc0c8e3c8919 100644 (file)
@@ -283,7 +283,7 @@ public class SimpleDayCell extends FocusableFlowPanel implements MouseUpHandler,
             eventDiv.setTimeSpecificEvent(false);
             Date from = e.getStart();
             Date to = e.getEnd();
-            if (e.getStyleName().length() > 0) {
+            if (!e.getStyleName().isEmpty()) {
                 eventDiv.addStyleName("month-event " + e.getStyleName());
             } else {
                 eventDiv.addStyleName("month-event");
index 4ed86b0b68eee07a9913cf1eaca9e6b7869ce919..bc5bb9c4a48742e7429d52ab40f80f33b5e03e87 100644 (file)
@@ -98,7 +98,7 @@ public class WeeklyLongEvents extends HorizontalPanel implements HasTooltipKey {
                     eventLabel.addStyleDependentName("continued-to");
                 }
                 final String extraStyle = calendarEvent.getStyleName();
-                if (extraStyle != null && extraStyle.length() > 0) {
+                if (extraStyle != null && !extraStyle.isEmpty()) {
                     eventLabel.addStyleDependentName(extraStyle + "-all-day");
                 }
                 if (!started) {
index 00fb4b86fa2c58a92bfe38b1a5ae4f6b66eeebf0..f226622359c44bbc3b94d6f4e52165d3d4f06d32 100644 (file)
@@ -136,7 +136,7 @@ public interface Validator extends Serializable {
          */
         public boolean isInvisible() {
             String msg = getMessage();
-            if (msg != null && msg.length() > 0) {
+            if (msg != null && !msg.isEmpty()) {
                 return false;
             }
             if (causes != null) {
index b7c838c09e5e43cec562f0df32e3ae3b3f6f2e26..6cbff702ad77bd126717873fa4d41d70754af67c 100644 (file)
@@ -146,7 +146,7 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> {
         }
         for (int i = 0; i < simplePropertyNames.length; i++) {
             String simplePropertyName = simplePropertyNames[i].trim();
-            if (simplePropertyName.length() > 0) {
+            if (!simplePropertyName.isEmpty()) {
                 lastSimplePropertyName = simplePropertyName;
                 lastClass = propertyClass;
                 try {
index 13cef7ece34152267abc7d660e5f6fead1467c8f..8b65f7fc446a1998ba3c87da1e92caffe0cae6a8 100644 (file)
@@ -187,7 +187,7 @@ public class StringToCollectionConverter
             }
             builder.append(delimiter);
         }
-        if (builder.length() > 0) {
+        if (builder.length() != 0) {
             return builder.substring(0, builder.length() - delimiter.length());
         } else {
             return builder.toString();
index ccc010924b2fbb9cd267ca925b308ec4e40f80f8..d02f504d567c8e70af0bae534412251d7e51a381 100644 (file)
@@ -73,7 +73,7 @@ public class RowId implements Serializable {
             builder.append(id);
             builder.append('/');
         }
-        if (builder.length() > 0) {
+        if (builder.length() != 0) {
             return builder.substring(0, builder.length() - 1);
         }
         return builder.toString();
index 45f33eefbe1b0b09543bb704207b27c0e0eea219..8c1282673ee96db5665f0043bf5c08e2faf44aae 100644 (file)
@@ -267,7 +267,7 @@ public class FreeformQuery extends AbstractTransactionalQuery
                 StatementHelper sh = ((FreeformStatementDelegate) delegate)
                         .getCountStatement();
                 if (sh != null && sh.getQueryString() != null
-                        && sh.getQueryString().length() > 0) {
+                        && !sh.getQueryString().isEmpty()) {
                     return true;
                 }
             } catch (UnsupportedOperationException e) {
@@ -276,7 +276,7 @@ public class FreeformQuery extends AbstractTransactionalQuery
         }
         try {
             String queryString = delegate.getQueryString(0, 50);
-            return queryString != null && queryString.length() > 0;
+            return queryString != null && !queryString.isEmpty();
         } catch (UnsupportedOperationException e) {
             return false;
         }
index a89818222cc09fa0f847795a5442e4898b4a7eb1..e89c72fa4ce25539505aa328221bfaa75cf7fbed 100644 (file)
@@ -465,7 +465,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
         // New option entered (and it is allowed)
         if (isNewItemsAllowed()) {
             final String newitem = (String) variables.get("newitem");
-            if (newitem != null && newitem.length() > 0) {
+            if (newitem != null && !newitem.isEmpty()) {
                 getNewItemHandler().addNewItem(newitem);
             }
         }
index 5fa82535bcd09a4069a6b4850040c6210fa805a6..72e8c6dffb5ff4508a22afee8663fb75ba3520e4 100644 (file)
@@ -327,7 +327,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
 
     @Override
     public boolean isEmpty() {
-        return super.isEmpty() || getValue().length() == 0;
+        return super.isEmpty() || getValue().isEmpty();
     }
 
     /**
index 0fea65ebce4cc7d85d74c44d7592c25003ed62a4..b37c9c7e2ba104c931e1656c5bad8f3c4d2f05d9 100644 (file)
@@ -1825,7 +1825,7 @@ public class Calendar extends AbstractLegacyComponent
 
         @Override
         public void weekClick(String event) {
-            if (event.length() > 0 && event.contains("w")) {
+            if (!event.isEmpty() && event.contains("w")) {
                 String[] splitted = event.split("w");
                 if (splitted.length == 2) {
                     try {
index 8a9db41624e17323c2071e88d58c909de240e975..b9960bba4f3f1e966b69e74bf3f134fa4d1f6228 100644 (file)
@@ -188,7 +188,7 @@ public class ComboBox extends AbstractSelect
     }
 
     private boolean isFilteringNeeded() {
-        return filterstring != null && filterstring.length() > 0
+        return filterstring != null && !filterstring.isEmpty()
                 && filteringMode != FilteringMode.OFF;
     }
 
@@ -762,7 +762,7 @@ public class ComboBox extends AbstractSelect
         } else if (isNewItemsAllowed()) {
             // New option entered (and it is allowed)
             final String newitem = (String) variables.get("newitem");
-            if (newitem != null && newitem.length() > 0) {
+            if (newitem != null && !newitem.isEmpty()) {
                 getNewItemHandler().addNewItem(newitem);
                 // rebuild list
                 filterstring = null;
index 3b6d4f7b5a539db2d750a7e3ef9f8186b43b70e5..1e4bf1df718eb2dfafecd9d1b7195edcff0a1c59 100644 (file)
@@ -294,7 +294,7 @@ public class RichTextArea extends AbstractField<String>
 
     @Override
     public boolean isEmpty() {
-        return super.isEmpty() || getValue().length() == 0;
+        return super.isEmpty() || getValue().isEmpty();
     }
 
     @Override
index 6ffbf6063e2a797880b0412d1fd5118b752cd226..cad1dc425d3db071e751a3b45f1e5ba6109fccc8 100644 (file)
@@ -129,7 +129,7 @@ public abstract class AbstractErrorMessage implements ErrorMessage {
                     sb.append("</div>\n");
                 }
             }
-            if (sb.length() > 0) {
+            if (sb.length() != 0) {
                 result = sb.toString();
             }
         }
index 1cba25fbf6ac24c37f6f8d930ff736a086f87c8d..6b43dc3a6462080250980af18b5691a546cb67e8 100644 (file)
@@ -659,7 +659,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
         mainDiv.addClass(context.getThemeName());
         mainDiv.addClass(context.getUIClass().getSimpleName()
                 .toLowerCase(Locale.ENGLISH));
-        if (style != null && style.length() != 0) {
+        if (style != null && !style.isEmpty()) {
             mainDiv.attr("style", style);
         }
         mainDiv.appendElement("div").addClass("v-app-loading");
index 4ad7097e3b7c74520b561385289d3487c0411060..1128bc85fd6670a0ddc6f3e8fd5e09d6e02ed082 100644 (file)
@@ -78,7 +78,7 @@ public abstract class LegacyApplicationUIProvider extends UIProvider {
         VaadinRequest request = event.getRequest();
         String pathInfo = request.getPathInfo();
         String name = null;
-        if (pathInfo != null && pathInfo.length() > 0) {
+        if (pathInfo != null && !pathInfo.isEmpty()) {
             Matcher matcher = WINDOW_NAME_PATTERN.matcher(pathInfo);
             if (matcher.matches()) {
                 // Skip the initial slash
index 385aa0bf9a3f0271390ab21b39399290045201f5..4c880c2a6b09e7c963784e4d66d4b986510af05c 100644 (file)
@@ -203,7 +203,7 @@ public class Page implements Serializable {
         private void paintContent(PaintTarget target) throws PaintException {
             target.startTag("open");
             target.addAttribute("src", resource);
-            if (name != null && name.length() > 0) {
+            if (name != null && !name.isEmpty()) {
                 target.addAttribute("name", name);
             }
             if (!tryToOpenAsPopup) {
index b1b34e1fef3d605329eaed6c67976102ec25b99f..d5894f4e12d4c786596d8de8b0fe180459ef8477 100644 (file)
@@ -98,7 +98,7 @@ public class SizeWithUnit implements Serializable {
                 unit = Unit.PIXELS;
             } else {
                 String symbol = matcher.group(2);
-                if ((symbol != null && symbol.length() > 0)
+                if ((symbol != null && !symbol.isEmpty())
                         || defaultUnit == null) {
                     unit = Unit.getUnitFromSymbol(symbol);
                 } else {
index 8fc0a76badcc0e4ea18b815211a7774f7e6addd4..4410aa4cb7589b0e8f599e0e43dc852598e0d556 100644 (file)
@@ -45,7 +45,7 @@ public class ThemeResource implements Resource {
         if (resourceId == null) {
             throw new NullPointerException("Resource ID must not be null");
         }
-        if (resourceId.length() == 0) {
+        if (resourceId.isEmpty()) {
             throw new IllegalArgumentException("Resource ID can not be empty");
         }
         if (resourceId.charAt(0) == '/') {
index d2498dddfcc725154ee1688e087f733daa8bcaed..638eeb047fe5a76cde99fde90c1a73d6ee3c0561 100644 (file)
@@ -1412,7 +1412,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
             servletPath = request.getContextPath() + request.getServletPath();
         }
 
-        if (servletPath.length() == 0
+        if (servletPath.isEmpty()
                 || servletPath.charAt(servletPath.length() - 1) != '/') {
             servletPath += "/";
         }
index a90f8e8d8a6fb060cae6e1c5450c9af599c1d4e9..43f78f7c1b96fdd11ee5854b8863a696fc282117 100644 (file)
@@ -476,7 +476,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout
             // handle expand ratio
             if (attr.hasKey(":expand")) {
                 String value = attr.get(":expand");
-                if (value.length() > 0) {
+                if (!value.isEmpty()) {
                     try {
                         float ratio = Float.valueOf(value);
                         setExpandRatio(newChild, ratio);
index af100e03f1366262828f8463bdb89ed56401252f..0d7e7fc619c2156db4188bfba672c5001af76248 100644 (file)
@@ -155,7 +155,7 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
         public void createNewItem(String itemValue) {
             // New option entered
             if (getNewItemHandler() != null && itemValue != null
-                    && itemValue.length() > 0) {
+                    && !itemValue.isEmpty()) {
                 getNewItemHandler().accept(itemValue);
             }
         }
index 0293b0a648c256f0834bc31bc85c559b5138c060..d44a02f52e1096e5bc5f8b9bc024826782ca74da 100644 (file)
@@ -307,7 +307,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
         // Workaround to make the CommunicationManager read the template file
         // and send it to the client
         String templateName = getState(false).templateName;
-        if (templateName != null && templateName.length() != 0) {
+        if (templateName != null && !templateName.isEmpty()) {
             Set<Object> usedResources = ((JsonPaintTarget) target)
                     .getUsedResources();
             String resourceName = "layouts/" + templateName + ".html";
index 9cf60faddc5ed1eacd572281926502e3ce73b29b..39d66bd0b041400feb45e05b8fabc6025c2c12f7 100644 (file)
@@ -139,7 +139,7 @@ public class MenuBar extends AbstractComponent
             }
 
             String description = item.getDescription();
-            if (description != null && description.length() > 0) {
+            if (description != null && !description.isEmpty()) {
                 target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION,
                         description);
             }
index dde1624352b368cbec8d871c9e25599d5c225d37..0fbfe9c6b5ba442b09f89ace41e4e97352b208cf 100644 (file)
@@ -327,7 +327,7 @@ public class DesignAttributeHandler implements Serializable {
         String[] words = propertyName.split("(?<!^)(?=[A-Z])");
         StringBuilder builder = new StringBuilder();
         for (int i = 0; i < words.length; i++) {
-            if (builder.length() > 0) {
+            if (builder.length() != 0) {
                 builder.append("-");
             }
             builder.append(words[i].toLowerCase());
index e3237ada531b7d5b523424a44dc5301ee085ad65..042fa77826b8f3a3e50b6c83cb141636c455ec0b 100644 (file)
@@ -530,7 +530,7 @@ public class DesignContext implements Serializable {
         // global id: only update the mapping, the id has already been set for
         // the component
         String id = component.getId();
-        if (id != null && id.length() > 0) {
+        if (id != null && !id.isEmpty()) {
             boolean mappingExists = mapId(id, component);
             if (mappingExists) {
                 throw new DesignException(
index f860e30e7c82e842d20f858414225ba4c71d9cdf..dfd70334308a1c99d800a43c29d20eafadd16915 100644 (file)
@@ -176,7 +176,7 @@ public class FieldBinder implements Serializable {
         try {
             // create and validate field name
             String fieldName = asFieldName(identifier);
-            if (fieldName.length() == 0) {
+            if (fieldName.isEmpty()) {
                 return false;
             }
             // validate that the field can be found
@@ -231,7 +231,7 @@ public class FieldBinder implements Serializable {
             }
         }
         // lowercase first letter
-        if (result.length() > 0 && Character.isLetter(result.charAt(0))) {
+        if (result.length() != 0 && Character.isLetter(result.charAt(0))) {
             result.setCharAt(0, Character.toLowerCase(result.charAt(0)));
         }
         return result.toString();
index b4f38928a9a58271510268ad10fc935f43f22b89..aade7e80b7e6c860fa62fcb130f141e77ca1834e 100644 (file)
@@ -123,7 +123,7 @@ public class DesignShortcutActionConverter
     @Override
     public Result<ShortcutAction> convertToModel(String value,
             ValueContext context) {
-        if (value.length() == 0) {
+        if (value.isEmpty()) {
             return Result.ok(null);
         }
 
index bdc8bc049bdae828674bb4d28b8508295ac89a22..88874ac4c8bdcc17603935d9d9080c1adb15a4a9 100644 (file)
@@ -69,6 +69,6 @@ public class CompileTransitionPropertyTest {
         // Only whitespace should remain after removing the style rules
         modifiedStyle = modifiedStyle.replaceAll("(\\s)", "");
         assertTrue("Unexpected style rules for .my-label: " + modifiedStyle,
-                modifiedStyle.length() == 0);
+                modifiedStyle.isEmpty());
     }
 }
\ No newline at end of file
index 92e03bed5ff64c92ed02756f26973b608eea0888..4f1b71687b58a476308726aaea10700010ffa6ac 100644 (file)
@@ -235,7 +235,7 @@ public class SharedUtil implements Serializable {
      * @return The modified URI with the get parameters in extraParams added.
      */
     public static String addGetParameters(String uri, String extraParams) {
-        if (extraParams == null || extraParams.length() == 0) {
+        if (extraParams == null || extraParams.isEmpty()) {
             return uri;
         }
         // RFC 3986: The query component is indicated by the first question
index bb38110bcc98975bede7ffabb0a94d21966675db..647c6575f14393a9e935dd64ee795ea090a85c91 100644 (file)
@@ -119,7 +119,7 @@ public class Parameters extends com.vaadin.server.LegacyApplication
             final String[] values = entry.getValue();
             String v = "";
             for (int j = 0; j < values.length; j++) {
-                if (v.length() > 0) {
+                if (!v.isEmpty()) {
                     v += ", ";
                 }
                 v += "'" + values[j] + "'";
index 707aa51d6fa2d2ec15aebef6c471ead46ede0c84..0f4c0440eae0a1f8dd34c553a72846551e08d438 100644 (file)
@@ -76,11 +76,11 @@ public class TestForContainerFilterable extends CustomComponent {
             @Override
             public void buttonClick(ClickEvent event) {
                 ic.removeAllContainerFilters();
-                if (fooFilter.getValue().length() > 0) {
+                if (!fooFilter.getValue().isEmpty()) {
                     ic.addContainerFilter("foo", fooFilter.getValue(), false,
                             false);
                 }
-                if (barFilter.getValue().length() > 0) {
+                if (!barFilter.getValue().isEmpty()) {
                     ic.addContainerFilter("bar", barFilter.getValue(), true,
                             true);
                 }
index 1410a3cfaee331bca690187ddaa29b9f4a5d2e5d..71a6ee9f0d731398dafb9ad642dea0c05d09c315 100644 (file)
@@ -52,7 +52,7 @@ public class OrderedLayoutCases extends AbstractReindeerTestUI {
                         public void valueChange(ValueChangeEvent event) {
                             String value = event.getProperty().getValue()
                                     .toString();
-                            if (value.length() == 0) {
+                            if (value.isEmpty()) {
                                 setCaption(null);
                             } else if (value.equals("Long")) {
                                 setCaption(
index fbc31c1295ad618a6509d04064e215837a66bee7..7bb2d30910f0f2dbfb5a9e2fb345b58a54f4350d 100644 (file)
@@ -57,7 +57,7 @@ public class TextFieldRelativeWidth extends AbstractReindeerTestUI {
             Object itemId = idc.addItemAt(size - 1);
             Item newItem = idc.getItem(itemId);
             TextField tf = new TextField();
-            if (inputPrompt != null && inputPrompt.length() > 0) {
+            if (inputPrompt != null && !inputPrompt.isEmpty()) {
                 tf.setInputPrompt(inputPrompt);
             }
             tf.setWidth("100%");
@@ -70,7 +70,7 @@ public class TextFieldRelativeWidth extends AbstractReindeerTestUI {
             newItem = idc.getItem(itemId);
 
             tf = new TextField();
-            if (inputPromptChild != null && inputPromptChild.length() > 0) {
+            if (inputPromptChild != null && !inputPromptChild.isEmpty()) {
                 tf.setInputPrompt(inputPromptChild);
             }
             tf.setWidth("100%");
index 3db3e208af14d29e5dc26dc8dd37d4db69b784e2..c8945e0e389bcc98921028b1b8cc252bb21657d7 100644 (file)
@@ -110,7 +110,7 @@ public class TextChangeEvents extends AbstractTestUIWithLog {
         }
 
         private String findMatch(String currentTextContent) {
-            if (currentTextContent.length() > 0) {
+            if (!currentTextContent.isEmpty()) {
                 for (int i = 0; i < names.length; i++) {
                     if (names[i].startsWith(currentTextContent)) {
                         return names[i];
index 9967980d165cbbc8d674a280e184f9c716af8237..0ae27ac6c1ea4a56dbfef880d88ab19f3eccbab1 100644 (file)
@@ -78,7 +78,7 @@ public class TextFieldWithPropertyFormatter extends TestBase {
             @Override
             public BigDecimal parse(String formattedValue) throws Exception {
                 if (formattedValue != null
-                        && formattedValue.trim().length() != 0) {
+                        && !formattedValue.trim().isEmpty()) {
                     BigDecimal value = (BigDecimal) df.parse(formattedValue);
                     value = value.setScale(2, BigDecimal.ROUND_HALF_UP);
                     return value;
index 6c86b16dda9b37b8421b92a51051c39fb523e186..cef3749a5078678dafc1718b4ade46f17ca5b44e 100644 (file)
@@ -138,7 +138,7 @@ public class TextFieldsValueChangeMode extends AbstractTestUIWithLog {
         }
 
         private String findMatch(String currentTextContent) {
-            if (currentTextContent.length() > 0) {
+            if (!currentTextContent.isEmpty()) {
                 for (int i = 0; i < names.length; i++) {
                     if (names[i].startsWith(currentTextContent)) {
                         return names[i];
index 6699cefa3903886adc15c8eaeb7539b1ec86a36e..b15a7c004a34d2fd74813fcecfbab8228d27ec90 100644 (file)
@@ -220,7 +220,7 @@ public abstract class BaseLayoutTestUI extends AbstractReindeerTestUI {
                 comp.setIcon(ICONS[i]);
             }
             if (ErrorMessage != null) {
-                if (ErrorMessage.length() == 0) {
+                if (ErrorMessage.isEmpty()) {
                     comp.setComponentError(new UserError(null));
                 } else {
                     comp.setComponentError(new UserError(ErrorMessage));
index 6a0aee96701f2b8bb71eb8022d61e1e6e74314d6..49ec4da0b2cffbdae98febf0940f6c0991e5153c 100644 (file)
@@ -35,7 +35,7 @@ public class MyPickerWidget extends ComplexPanel {
     }
 
     public void setButtonText(String buttonText, boolean adjustSpace) {
-        if (buttonText == null || buttonText.length() == 0) {
+        if (buttonText == null || buttonText.isEmpty()) {
             buttonText = "...";
         }
         button.setText(buttonText);
index 403cee1882d62861d05c8b20b42f6e6c1a687001..6d7a67cfa8bbe63b20a31c1abd6af5b9055c57cd 100644 (file)
@@ -153,7 +153,7 @@ public class CommonParts extends VerticalLayout implements View {
                 title.setPlaceholder("Title for the notification");
                 title.addValueChangeListener(event -> {
                     if (title.getValue() == null
-                            || title.getValue().length() == 0) {
+                            || title.getValue().isEmpty()) {
                         notification.setCaption(null);
                     } else {
                         notification.setCaption(title.getValue());
@@ -167,7 +167,7 @@ public class CommonParts extends VerticalLayout implements View {
                 description.addStyleName(ValoTheme.TEXTAREA_SMALL);
                 description.addValueChangeListener(listener -> {
                     if (description.getValue() == null
-                            || description.getValue().length() == 0) {
+                            || description.getValue().isEmpty()) {
                         notification.setDescription(null);
                     } else {
                         notification.setDescription(description.getValue());
@@ -218,11 +218,11 @@ public class CommonParts extends VerticalLayout implements View {
                                         + item.getText().toLowerCase();
                             }
                         }
-                        if (styleString.trim().length() > 0) {
+                        if (!styleString.trim().isEmpty()) {
                             notification.setStyleName(
                                     (typeString + " " + styleString.trim())
                                             .trim());
-                        } else if (typeString.length() > 0) {
+                        } else if (!typeString.isEmpty()) {
                             notification.setStyleName(typeString.trim());
                         } else {
                             notification.setStyleName(null);
index fc9ccfe04fa76c050110cd37e4abea8688e4616d..406309f4712cc354bd99a772c5b97ef36916795f 100644 (file)
@@ -122,7 +122,7 @@ public class TextChangeEvents extends TestBase {
         }
 
         private String findMatch(String currentTextContent) {
-            if (currentTextContent.length() > 0) {
+            if (!currentTextContent.isEmpty()) {
                 for (int i = 0; i < names.length; i++) {
                     if (names[i].startsWith(currentTextContent)) {
                         return names[i];