diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-09-21 10:51:51 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-21 11:51:51 +0300 |
commit | 867006d2f81aa813c36f614fc6f1b98a5937c5f3 (patch) | |
tree | fb2c34b1b58db8b3610a4a47010196069e90c436 | |
parent | 719b12e44afc8b62458b1e29d1503e28544acc24 (diff) | |
download | vaadin-framework-867006d2f81aa813c36f614fc6f1b98a5937c5f3.tar.gz vaadin-framework-867006d2f81aa813c36f614fc6f1b98a5937c5f3.zip |
Use String.isEmpty() (#10045)
64 files changed, 94 insertions, 94 deletions
diff --git a/client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java b/client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java index 864582546b..4057c531d6 100644 --- a/client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java +++ b/client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java @@ -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); diff --git a/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java b/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java index f0a6e7057a..05449f1126 100644 --- a/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java +++ b/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java @@ -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); diff --git a/client/src/main/java/com/vaadin/client/ResourceLoader.java b/client/src/main/java/com/vaadin/client/ResourceLoader.java index 53967a74f7..12922dca00 100644 --- a/client/src/main/java/com/vaadin/client/ResourceLoader.java +++ b/client/src/main/java/com/vaadin/client/ResourceLoader.java @@ -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); } } diff --git a/client/src/main/java/com/vaadin/client/VErrorMessage.java b/client/src/main/java/com/vaadin/client/VErrorMessage.java index b87704f3e0..0baa1baff1 100644 --- a/client/src/main/java/com/vaadin/client/VErrorMessage.java +++ b/client/src/main/java/com/vaadin/client/VErrorMessage.java @@ -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 diff --git a/client/src/main/java/com/vaadin/client/WidgetUtil.java b/client/src/main/java/com/vaadin/client/WidgetUtil.java index 3390881b72..d24a1d53a5 100644 --- a/client/src/main/java/com/vaadin/client/WidgetUtil.java +++ b/client/src/main/java/com/vaadin/client/WidgetUtil.java @@ -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", ""); diff --git a/client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java b/client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java index f01c693c4c..ddab95d2c9 100644 --- a/client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java +++ b/client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java @@ -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; } diff --git a/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index c7abe8c15f..77e1ee0a09 100644 --- a/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -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 { diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java index ae24ed850f..44a60b9fd5 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java @@ -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 diff --git a/client/src/main/java/com/vaadin/client/ui/VAccordion.java b/client/src/main/java/com/vaadin/client/ui/VAccordion.java index 73f48639f3..16c16935d0 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAccordion.java +++ b/client/src/main/java/com/vaadin/client/ui/VAccordion.java @@ -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); } diff --git a/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java b/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java index 427c4011a5..a957690526 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java +++ b/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java @@ -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; } diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java index ebb993702c..c872026ac7 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -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%"); } } diff --git a/client/src/main/java/com/vaadin/client/ui/VLink.java b/client/src/main/java/com/vaadin/client/ui/VLink.java index ede020e572..84aac0f17e 100644 --- a/client/src/main/java/com/vaadin/client/ui/VLink.java +++ b/client/src/main/java/com/vaadin/client/ui/VLink.java @@ -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(); diff --git a/client/src/main/java/com/vaadin/client/ui/VNotification.java b/client/src/main/java/com/vaadin/client/ui/VNotification.java index e5358a3db7..0eaee0102c 100644 --- a/client/src/main/java/com/vaadin/client/ui/VNotification.java +++ b/client/src/main/java/com/vaadin/client/ui/VNotification.java @@ -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) { diff --git a/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java b/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java index 15b0d6f043..4f0bed52ed 100644 --- a/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java +++ b/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java @@ -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; } diff --git a/client/src/main/java/com/vaadin/client/ui/VUpload.java b/client/src/main/java/com/vaadin/client/ui/VUpload.java index d25508d29a..dd4c295492 100644 --- a/client/src/main/java/com/vaadin/client/ui/VUpload.java +++ b/client/src/main/java/com/vaadin/client/ui/VUpload.java @@ -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 diff --git a/client/src/main/java/com/vaadin/client/ui/VWindow.java b/client/src/main/java/com/vaadin/client/ui/VWindow.java index c6d817587b..9e4aad0d2c 100644 --- a/client/src/main/java/com/vaadin/client/ui/VWindow.java +++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java @@ -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) { diff --git a/client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java index 815509c44b..c837570c85 100644 --- a/client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -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"; diff --git a/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java b/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java index 4e28fb6349..dc8d30e517 100644 --- a/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java @@ -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 diff --git a/client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java b/client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java index 8a84208ea8..1473af44ae 100644 --- a/client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java +++ b/client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java @@ -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")); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java index 64cc713e20..b78ad3928b 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java @@ -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%"); } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java index ee9048d4c2..2140610559 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java @@ -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()); } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java index 2e20abe4a0..cf8d53d42a 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java @@ -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 diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java index 4969f19933..1a93e04e1e 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java @@ -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 diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java index 5695365db8..65b49b8434 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java @@ -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); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java index f671d7c21d..df0d74d3b5 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java @@ -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"); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java index 4ed86b0b68..bc5bb9c4a4 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java @@ -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) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java index 00fb4b86fa..f226622359 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java @@ -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) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java index b7c838c09e..6cbff702ad 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java @@ -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 { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java index 13cef7ece3..8b65f7fc44 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java @@ -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(); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java index ccc010924b..d02f504d56 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java @@ -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(); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java index 45f33eefbe..8c1282673e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java @@ -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; } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java index a89818222c..e89c72fa4c 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java @@ -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); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java index 5fa82535bc..72e8c6dffb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java @@ -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(); } /** diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java index 0fea65ebce..b37c9c7e2b 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java @@ -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 { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java index 8a9db41624..b9960bba4f 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java @@ -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; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java index 3b6d4f7b5a..1e4bf1df71 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java @@ -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 diff --git a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java index 6ffbf6063e..cad1dc425d 100644 --- a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java +++ b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java @@ -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(); } } diff --git a/server/src/main/java/com/vaadin/server/BootstrapHandler.java b/server/src/main/java/com/vaadin/server/BootstrapHandler.java index 1cba25fbf6..6b43dc3a64 100644 --- a/server/src/main/java/com/vaadin/server/BootstrapHandler.java +++ b/server/src/main/java/com/vaadin/server/BootstrapHandler.java @@ -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"); diff --git a/server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java b/server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java index 4ad7097e3b..1128bc85fd 100644 --- a/server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java +++ b/server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java @@ -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 diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java index 385aa0bf9a..4c880c2a6b 100644 --- a/server/src/main/java/com/vaadin/server/Page.java +++ b/server/src/main/java/com/vaadin/server/Page.java @@ -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) { diff --git a/server/src/main/java/com/vaadin/server/SizeWithUnit.java b/server/src/main/java/com/vaadin/server/SizeWithUnit.java index b1b34e1fef..d5894f4e12 100644 --- a/server/src/main/java/com/vaadin/server/SizeWithUnit.java +++ b/server/src/main/java/com/vaadin/server/SizeWithUnit.java @@ -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 { diff --git a/server/src/main/java/com/vaadin/server/ThemeResource.java b/server/src/main/java/com/vaadin/server/ThemeResource.java index 8fc0a76bad..4410aa4cb7 100644 --- a/server/src/main/java/com/vaadin/server/ThemeResource.java +++ b/server/src/main/java/com/vaadin/server/ThemeResource.java @@ -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) == '/') { diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java index d2498dddfc..638eeb047f 100644 --- a/server/src/main/java/com/vaadin/server/VaadinServlet.java +++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java @@ -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 += "/"; } diff --git a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java index a90f8e8d8a..43f78f7c1b 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java @@ -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); diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index af100e03f1..0d7e7fc619 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -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); } } diff --git a/server/src/main/java/com/vaadin/ui/CustomLayout.java b/server/src/main/java/com/vaadin/ui/CustomLayout.java index 0293b0a648..d44a02f52e 100644 --- a/server/src/main/java/com/vaadin/ui/CustomLayout.java +++ b/server/src/main/java/com/vaadin/ui/CustomLayout.java @@ -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"; diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java index 9cf60faddc..39d66bd0b0 100644 --- a/server/src/main/java/com/vaadin/ui/MenuBar.java +++ b/server/src/main/java/com/vaadin/ui/MenuBar.java @@ -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); } diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java index dde1624352..0fbfe9c6b5 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java @@ -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()); diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java b/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java index e3237ada53..042fa77826 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java @@ -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( diff --git a/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java b/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java index f860e30e7c..dfd7033430 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java +++ b/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java @@ -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(); diff --git a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java index b4f38928a9..aade7e80b7 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java +++ b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java @@ -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); } diff --git a/server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java b/server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java index bdc8bc049b..88874ac4c8 100644 --- a/server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java +++ b/server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java @@ -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 diff --git a/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java b/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java index 92e03bed5f..4f1b71687b 100644 --- a/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java +++ b/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java @@ -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 diff --git a/uitest/src/main/java/com/vaadin/tests/Parameters.java b/uitest/src/main/java/com/vaadin/tests/Parameters.java index bb38110bcc..647c6575f1 100644 --- a/uitest/src/main/java/com/vaadin/tests/Parameters.java +++ b/uitest/src/main/java/com/vaadin/tests/Parameters.java @@ -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] + "'"; diff --git a/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java b/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java index 707aa51d6f..0f4c0440ea 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java @@ -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); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index 1410a3cfae..71a6ee9f0d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -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( diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java b/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java index fbc31c1295..7bb2d30910 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java @@ -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%"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java index 3db3e208af..c8945e0e38 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java @@ -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]; diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java index 9967980d16..0ae27ac6c1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java @@ -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; diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java index 6c86b16dda..cef3749a50 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java @@ -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]; diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java index 6699cefa39..b15a7c004a 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java @@ -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)); diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java index 6a0aee9670..49ec4da0b2 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java @@ -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); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java index 403cee1882..6d7a67cfa8 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java @@ -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); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java index fc9ccfe04f..406309f471 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java @@ -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]; |