diff options
59 files changed, 122 insertions, 116 deletions
diff --git a/client/src/main/java/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/main/java/com/vaadin/client/componentlocator/ComponentLocator.java index 9669131651..e0dbfca6b3 100644 --- a/client/src/main/java/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/main/java/com/vaadin/client/componentlocator/ComponentLocator.java @@ -152,7 +152,7 @@ public class ComponentLocator { for (LocatorStrategy strategy : locatorStrategies) { if (strategy.validatePath(path)) { List<Element> elements = strategy.getElementsByPath(path); - if (elements.size() > 0) { + if (!elements.isEmpty()) { for (Element e : elements) { jsElements.push(e); } @@ -184,7 +184,7 @@ public class ComponentLocator { if (strategy.validatePath(path)) { List<Element> elements = strategy .getElementsByPathStartingAt(path, root); - if (elements.size() > 0) { + if (!elements.isEmpty()) { for (Element e : elements) { jsElements.push(e); } 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 b650702c08..2c2ff5707c 100644 --- a/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -118,7 +118,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { path.add(pathFragment); } - if (path.size() == 0) { + if (path.isEmpty()) { // If we didn't find a single element, return null.. return null; } @@ -277,7 +277,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { public List<Element> getElementsByPath(String path) { List<SelectorPredicate> postFilters = SelectorPredicate .extractPostFilterPredicates(path); - if (postFilters.size() > 0) { + if (!postFilters.isEmpty()) { path = path.substring(1, path.lastIndexOf(')')); } @@ -347,7 +347,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { Element root) { List<SelectorPredicate> postFilters = SelectorPredicate .extractPostFilterPredicates(path); - if (postFilters.size() > 0) { + if (!postFilters.isEmpty()) { path = path.substring(1, path.lastIndexOf(')')); } @@ -617,7 +617,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { List<Integer> widgetTags = new ArrayList<>(); widgetTags.addAll(getTags(widgetName)); - if (widgetTags.size() == 0) { + if (widgetTags.isEmpty()) { widgetTags.addAll(getTags("com.vaadin.ui." + widgetName)); } @@ -631,7 +631,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { final String simpleName = getSimpleClassName(name); final String fullName = getFullClassName(name); - if (widgetTags.size() > 0) { + if (!widgetTags.isEmpty()) { Integer[] foundTags = client.getConfiguration() .getTagsForServerSideClassName(fullName); for (int tag : foundTags) { diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java index bc94293e78..3414133a9d 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java @@ -141,7 +141,7 @@ public class GridDragSourceConnector extends DragSourceExtensionConnector { draggedItems = getDraggedRows(nativeEvent); // Ignore event if there are no items dragged - if (draggedItems.size() == 0) { + if (draggedItems.isEmpty()) { return; } @@ -214,9 +214,12 @@ public class GridDragSourceConnector extends DragSourceExtensionConnector { final Element selectionColumnCell = getGrid().getSelectionColumn() .isPresent() // -1 is used when even selection column is not frozen - && frozenColumnCount != -1 ? draggedRowElement - .removeChild(draggedRowElement.getFirstChild()) - .cast() : null; + && frozenColumnCount != -1 + ? draggedRowElement + .removeChild( + draggedRowElement.getFirstChild()) + .cast() + : null; final List<String> frozenCellsTransforms = new ArrayList<>(); for (int i = 0; i < getGrid().getColumnCount(); i++) { @@ -331,7 +334,7 @@ public class GridDragSourceConnector extends DragSourceExtensionConnector { return; } // Ignore event if there are no items dragged - if (draggedItems != null && draggedItems.size() > 0) { + if (draggedItems != null && !draggedItems.isEmpty()) { super.onDragEnd(event); } @@ -448,8 +451,8 @@ public class GridDragSourceConnector extends DragSourceExtensionConnector { * @return Stream of dragged table row elements. */ private Stream<TableRowElement> getDraggedRowElementStream() { - return draggedItems.stream() - .map(row -> ((AbstractRemoteDataSource<JsonObject>) gridConnector + return draggedItems.stream().map( + row -> ((AbstractRemoteDataSource<JsonObject>) gridConnector .getDataSource()).indexOf(row)) .map(getGridBody()::getRowElement); } diff --git a/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java b/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java index a1bcae5524..88a85cb764 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java @@ -83,17 +83,17 @@ public class AnalyzeLayoutsPanel extends FlowPanel { Set<ComponentConnector> zeroWidthComponents = new HashSet<>(); findZeroSizeComponents(zeroHeightComponents, zeroWidthComponents, ac.getUIConnector()); - if (zeroHeightComponents.size() > 0 || zeroWidthComponents.size() > 0) { + if (!zeroHeightComponents.isEmpty() || !zeroWidthComponents.isEmpty()) { add(new HTML("<h4> Client side notifications</h4>" + " <em>The following relative sized components were " + "rendered to a zero size container on the client side." + " Note that these are not necessarily invalid " + "states, but reported here as they might be.</em>")); - if (zeroHeightComponents.size() > 0) { + if (!zeroHeightComponents.isEmpty()) { add(new HTML("<p><strong>Vertically zero size:</strong></p>")); printClientSideDetectedIssues(zeroHeightComponents, ac); } - if (zeroWidthComponents.size() > 0) { + if (!zeroWidthComponents.isEmpty()) { add(new HTML( "<p><strong>Horizontally zero size:</strong></p>")); printClientSideDetectedIssues(zeroWidthComponents, ac); diff --git a/client/src/main/java/com/vaadin/client/debug/internal/InfoSection.java b/client/src/main/java/com/vaadin/client/debug/internal/InfoSection.java index c0efe72b78..9e688349ad 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/InfoSection.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/InfoSection.java @@ -142,7 +142,7 @@ public class InfoSection implements Section { clear(); List<ApplicationConnection> apps = ApplicationConfiguration .getRunningApplications(); - if (apps.size() == 0) { + if (apps.isEmpty()) { // try again in a while refresher.schedule(1000); } else { diff --git a/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java index 268924b143..07da3fbd4a 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java @@ -80,7 +80,7 @@ public class SelectorPath { String tmpPath = path; List<SelectorPredicate> postFilters = SelectorPredicate .extractPostFilterPredicates(path); - if (postFilters.size() > 0) { + if (!postFilters.isEmpty()) { tmpPath = tmpPath.substring(1, tmpPath.lastIndexOf(')')); if (tmpPath.contains("#")) { // FIXME: SubParts should be handled. diff --git a/client/src/main/java/com/vaadin/client/extensions/FileDropTargetConnector.java b/client/src/main/java/com/vaadin/client/extensions/FileDropTargetConnector.java index 2d4048bc78..6d9a5c3bba 100644 --- a/client/src/main/java/com/vaadin/client/extensions/FileDropTargetConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/FileDropTargetConnector.java @@ -80,7 +80,7 @@ public class FileDropTargetConnector extends DropTargetExtensionConnector { */ private void uploadNextFile() { Scheduler.get().scheduleDeferred(() -> { - if (!uploading && uploadUrls.size() > 0) { + if (!uploading && !uploadUrls.isEmpty()) { uploading = true; String nextId = uploadUrls.keySet().stream().findAny().get(); @@ -124,7 +124,7 @@ public class FileDropTargetConnector extends DropTargetExtensionConnector { } // Request a list of upload URLs for the dropped files - if (fileParams.size() > 0) { + if (!fileParams.isEmpty()) { getRpcProxy(FileDropTargetRpc.class).drop(fileParams); } @@ -197,7 +197,8 @@ public class FileDropTargetConnector extends DropTargetExtensionConnector { protected FileUploadXHR() { } - public final native void postFile(File file) /*-{ + public final native void postFile(File file) + /*-{ this.setRequestHeader('Content-Type', 'multipart/form-data'); this.send(file); }-*/; diff --git a/client/src/main/java/com/vaadin/client/extensions/ResponsiveConnector.java b/client/src/main/java/com/vaadin/client/extensions/ResponsiveConnector.java index 7115c1e3c6..3af049c635 100644 --- a/client/src/main/java/com/vaadin/client/extensions/ResponsiveConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/ResponsiveConnector.java @@ -107,7 +107,7 @@ public class ResponsiveConnector extends AbstractExtensionConnector selectors.append('.').append(primaryStyle); if (target.getState().styles != null - && target.getState().styles.size() > 0) { + && !target.getState().styles.isEmpty()) { for (String style : target.getState().styles) { selectors.append(",.").append(style); selectors.append(",.").append(primaryStyle).append('.') 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 37b94ef8d6..5d98fd25d6 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -1067,7 +1067,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, * Gets the preferred height of the menu including pageItemsCount items. */ String getPreferredHeight(int pageItemsCount) { - if (currentSuggestions.size() > 0) { + if (!currentSuggestions.isEmpty()) { final int pixels = getPreferredHeight() / currentSuggestions.size() * pageItemsCount; return pixels + "px"; @@ -1260,7 +1260,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, */ int getItemOffsetHeight() { List<MenuItem> items = getItems(); - return items != null && items.size() > 0 + return items != null && !items.isEmpty() ? items.get(0).getOffsetHeight() : 0; } @@ -1270,7 +1270,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, */ int getItemOffsetWidth() { List<MenuItem> items = getItems(); - return items != null && items.size() > 0 + return items != null && !items.isEmpty() ? items.get(0).getOffsetWidth() : 0; } diff --git a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java index 20a0afcf0d..0202cdf430 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java +++ b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java @@ -248,7 +248,7 @@ public class VDragAndDropWrapper extends VCustomComponent @Override public void execute() { if (!uploading) { - if (fileIds.size() > 0) { + if (!fileIds.isEmpty()) { uploading = true; final Integer fileId = fileIds.remove(0); diff --git a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java index 8f0026dc14..432f44fe05 100644 --- a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java +++ b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java @@ -1116,7 +1116,7 @@ public class VMenuBar extends SimpleFocusablePanel // Only collapse if there is more than one item in the root menu and the // menu has an explicit size if ((getItems().size() > 1 || (collapsedRootItems != null - && collapsedRootItems.getItems().size() > 0)) + && !collapsedRootItems.getItems().isEmpty())) && getElement().getStyle().getProperty("width") != null && moreItem != null) { @@ -1144,7 +1144,7 @@ public class VMenuBar extends SimpleFocusablePanel } int widthReduced = 0; - while (widthReduced < widthNeeded && getItems().size() > 0) { + while (widthReduced < widthNeeded && !getItems().isEmpty()) { // Move last root menu item to collapsed menu CustomMenuItem collapse = getItems() .get(getItems().size() - 1); @@ -1152,21 +1152,21 @@ public class VMenuBar extends SimpleFocusablePanel removeItem(collapse); collapsedRootItems.addItem(collapse, 0); } - } else if (collapsedRootItems.getItems().size() > 0) { + } else if (!collapsedRootItems.getItems().isEmpty()) { // Space available for items: expand first items from collapsed // menu int widthAvailable = diff + moreItemWidth; int widthGrowth = 0; while (widthAvailable > widthGrowth - && collapsedRootItems.getItems().size() > 0) { + && !collapsedRootItems.getItems().isEmpty()) { // Move first item from collapsed menu to the root menu CustomMenuItem expand = collapsedRootItems.getItems() .get(0); collapsedRootItems.removeItem(expand); addItem(expand); widthGrowth += expand.getOffsetWidth(); - if (collapsedRootItems.getItems().size() > 0) { + if (!collapsedRootItems.getItems().isEmpty()) { widthAvailable -= moreItemWidth; } if (widthGrowth > widthAvailable) { @@ -1177,7 +1177,7 @@ public class VMenuBar extends SimpleFocusablePanel } } } - if (collapsedRootItems.getItems().size() > 0) { + if (!collapsedRootItems.getItems().isEmpty()) { addItem(moreItem); } } 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 c39da6d168..df2c4b17f3 100644 --- a/client/src/main/java/com/vaadin/client/ui/VWindow.java +++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java @@ -327,7 +327,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } private static VWindow getTopmostWindow() { - if (windowOrder.size() > 0) { + if (!windowOrder.isEmpty()) { return windowOrder.get(windowOrder.size() - 1); } return null; diff --git a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBar.java b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBar.java index 099cf15489..fae876165b 100644 --- a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBar.java +++ b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBar.java @@ -331,7 +331,7 @@ public class MenuBar extends Widget implements PopupListener { * @return the first item from the menu or null if no items. */ public MenuItem getFirstItem() { - return items != null && items.size() > 0 ? items.get(0) : null; + return items != null && !items.isEmpty() ? items.get(0) : null; } /** @@ -341,7 +341,7 @@ public class MenuBar extends Widget implements PopupListener { * @return the last item from the menu or null if no items. */ public MenuItem getLastItem() { - return items != null && items.size() > 0 ? items.get(items.size() - 1) + return items != null && !items.isEmpty() ? items.get(items.size() - 1) : null; } @@ -627,7 +627,7 @@ public class MenuBar extends Widget implements PopupListener { */ private void onShow() { // Select the first item when a menu is shown. - if (items.size() > 0) { + if (!items.isEmpty()) { selectItem(items.get(0)); } } diff --git a/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java b/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java index 14cb2e6523..07fc05622b 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java @@ -159,11 +159,12 @@ public class ListSorter<T> { if (result != 0) { return o.getDirection() == SortDirection.ASCENDING - ? result : -result; + ? result + : -result; } } - if (order.size() > 0) { + if (!order.isEmpty()) { return order.get(0) .getDirection() == SortDirection.ASCENDING ? a.hashCode() - b.hashCode() diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index 6adc0cbef9..61887dd980 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -425,7 +425,7 @@ public class Escalator extends Widget velocity = delta / ellapsed; // if last speed was so low, reset speeds and start // storing again - if (speeds.size() > 0 && !validSpeed(speeds.get(0))) { + if (!speeds.isEmpty() && !validSpeed(speeds.get(0))) { speeds.clear(); run = true; } 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 b825cec550..940240a773 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 @@ -1069,7 +1069,7 @@ public class VFilterSelect extends Composite * Gets the preferred height of the menu including pageItemsCount items. */ String getPreferredHeight(int pageItemsCount) { - if (currentSuggestions.size() > 0) { + if (!currentSuggestions.isEmpty()) { final int pixels = (getPreferredHeight() / currentSuggestions.size()) * pageItemsCount; return pixels + "px"; @@ -1298,7 +1298,7 @@ public class VFilterSelect extends Composite */ int getItemOffsetHeight() { List<MenuItem> items = getItems(); - return items != null && items.size() > 0 + return items != null && !items.isEmpty() ? items.get(0).getOffsetHeight() : 0; } @@ -1308,7 +1308,7 @@ public class VFilterSelect extends Composite */ int getItemOffsetWidth() { List<MenuItem> items = getItems(); - return items != null && items.size() > 0 + return items != null && !items.isEmpty() ? items.get(0).getOffsetWidth() : 0; } 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 ce97348589..12738541aa 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 @@ -1312,7 +1312,7 @@ public class VScrollTable extends FlowPanel // that is the same as the previous selection. This prevents // unwanted scrolling (#18247). boolean rowsUnSelected = removeUnselectedRowKeys(selectedKeys); - boolean updateFocus = rowsUnSelected || selectedRowKeys.size() == 0 + boolean updateFocus = rowsUnSelected || selectedRowKeys.isEmpty() || focusedRow == null; if (scrollBody != null) { for (Widget w : scrollBody) { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java index 81d71e809a..38c2f40c7c 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java @@ -459,7 +459,7 @@ public class VTree extends FocusElementPanel public void setSelected(TreeNode treeNode, boolean selected) { if (selected) { if (!isMultiselect) { - while (selectedIds.size() > 0) { + while (!selectedIds.isEmpty()) { final String id = selectedIds.iterator().next(); final TreeNode oldSelection = getNodeByKey(id); if (oldSelection != null) { @@ -1725,7 +1725,7 @@ public class VTree extends FocusElementPanel TreeNode node = null; // If node is open and has children then move in to the children if (!focusedNode.isLeaf() && focusedNode.getState() - && focusedNode.getChildren().size() > 0) { + && !focusedNode.getChildren().isEmpty()) { node = focusedNode.getChildren().get(0); } else { // Move down to the next sibling @@ -1906,8 +1906,7 @@ public class VTree extends FocusElementPanel * @return The bottom most child */ private TreeNode getLastVisibleChildInTree(TreeNode root) { - if (root.isLeaf() || !root.getState() - || root.getChildren().size() == 0) { + if (root.isLeaf() || !root.getState() || root.getChildren().isEmpty()) { return root; } List<TreeNode> children = root.getChildren(); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java index b4a00559b1..2fc55c7f58 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java @@ -334,7 +334,7 @@ public class TableConnector extends AbstractFieldConnector // in selection and exists with same index getWidget().setRowFocus(getWidget().getRenderedRowByKey( getWidget().focusedRow.getKey())); - } else if (getWidget().selectedRowKeys.size() > 0) { + } else if (!getWidget().selectedRowKeys.isEmpty()) { // try to focus any row in selection getWidget().setRowFocus(getWidget().getRenderedRowByKey( getWidget().selectedRowKeys.iterator().next())); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListSorter.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListSorter.java index 24d1eec06c..22bc9e7508 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListSorter.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListSorter.java @@ -159,11 +159,12 @@ public class ListSorter<T> { if (result != 0) { return o.getDirection() == SortDirection.ASCENDING - ? result : -result; + ? result + : -result; } } - if (order.size() > 0) { + if (!order.isEmpty()) { return order.get(0) .getDirection() == SortDirection.ASCENDING ? a.hashCode() - b.hashCode() diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java index 9751b0909f..4b6ce1ad58 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java @@ -104,7 +104,7 @@ public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T> @Override public boolean deselectAll() { - if (selectedRows.size() > 0) { + if (!selectedRows.isEmpty()) { @SuppressWarnings("unchecked") final LinkedHashSet<RowHandle<T>> selectedRowsClone = (LinkedHashSet<RowHandle<T>>) selectedRows @@ -140,7 +140,7 @@ public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T> } } - if (added.size() > 0) { + if (!added.isEmpty()) { grid.fireEvent(new SelectionEvent<T>(grid, added, null, isBeingBatchSelected())); @@ -164,7 +164,7 @@ public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T> } } - if (removed.size() > 0) { + if (!removed.isEmpty()) { grid.fireEvent(new SelectionEvent<T>(grid, null, removed, isBeingBatchSelected())); return true; diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java index 65ab2b4a71..c44f08ecc9 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java @@ -421,7 +421,7 @@ public class Escalator extends Widget velocity = delta / ellapsed; // if last speed was so low, reset speeds and start // storing again - if (speeds.size() > 0 && !validSpeed(speeds.get(0))) { + if (!speeds.isEmpty() && !validSpeed(speeds.get(0))) { speeds.clear(); run = true; } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java index 6457bd562d..793da7e7ff 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java @@ -45,7 +45,8 @@ import com.vaadin.v7.data.Validator; * @author Petri Hakala * @author Henri Sara * - * @deprecated See {@link BeanValidationBinder} and {@link com.vaadin.data.validator.BeanValidator} + * @deprecated See {@link BeanValidationBinder} and + * {@link com.vaadin.data.validator.BeanValidator} */ @Deprecated public class BeanValidator implements Validator { @@ -117,7 +118,7 @@ public class BeanValidator implements Validator { public void validate(final Object value) throws InvalidValueException { Set<?> violations = getJavaxBeanValidator().validateValue(beanClass, propertyName, value); - if (violations.size() > 0) { + if (!violations.isEmpty()) { InvalidValueException[] causes = new InvalidValueException[violations .size()]; int i = 0; 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 45b16f0381..03a091a92a 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 @@ -490,8 +490,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } } - if (!isNullSelectionAllowed() - && acceptedSelections.size() < 1) { + if (!isNullSelectionAllowed() && acceptedSelections.isEmpty()) { // empty selection not allowed, keep old value markAsDirty(); return; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java index 2e797cb7a9..d1c17d0414 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java @@ -1058,7 +1058,7 @@ public class Form extends AbstractField<Object> */ private Field<?> getFirstFocusableField() { Collection<?> itemPropertyIds = getItemPropertyIds(); - if (itemPropertyIds != null && itemPropertyIds.size() > 0) { + if (itemPropertyIds != null && !itemPropertyIds.isEmpty()) { for (Object id : itemPropertyIds) { if (id != null) { Field<?> field = getField(id); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java index ded75d0755..7b3289f1ad 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java @@ -2846,7 +2846,7 @@ public class Grid extends AbstractComponent protected void readDesign(Element cellElement, DesignContext designContext) { if (!cellElement.hasAttr("plain-text")) { - if (cellElement.children().size() > 0 + if (!cellElement.children().isEmpty() && cellElement.child(0).tagName().contains("-")) { setComponent( designContext.readDesign(cellElement.child(0))); @@ -3124,7 +3124,7 @@ public class Grid extends AbstractComponent */ protected void readDesign(Element tableSectionElement, DesignContext designContext) throws DesignException { - while (rows.size() > 0) { + while (!rows.isEmpty()) { removeRow(0); } @@ -7504,7 +7504,7 @@ public class Grid extends AbstractComponent "selection-mode", attrs, SelectionMode.class)); } - if (design.children().size() > 0) { + if (!design.children().isEmpty()) { if (design.children().size() > 1 || !design.child(0).tagName().equals("table")) { throw new DesignException( diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java index 7738c166f7..2b151c6a5c 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java @@ -605,7 +605,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } } - if (!isNullSelectionAllowed() && s.size() < 1) { + if (!isNullSelectionAllowed() && s.isEmpty()) { // empty selection not allowed, keep old value markAsDirty(); return; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TreeTable.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TreeTable.java index 4ea45422d3..88beb799a7 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TreeTable.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TreeTable.java @@ -226,7 +226,7 @@ public class TreeTable extends Table implements Hierarchical { @Override public Object lastItemId() { - if (getPreOrder().size() > 0) { + if (!getPreOrder().isEmpty()) { return getPreOrder().get(getPreOrder().size() - 1); } else { return null; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractHierarchicalContainerTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractHierarchicalContainerTestBase.java index 816dc251b5..2b5f912f50 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractHierarchicalContainerTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractHierarchicalContainerTestBase.java @@ -73,7 +73,7 @@ public abstract class AbstractHierarchicalContainerTestBase Collection<?> children = container.getChildren(rootId); assertNotNull(rootId + " should have children", children); assertTrue(rootId + " should have children", - (children.size() > 0)); + !children.isEmpty()); // getParent for (Object childId : children) { assertEquals(container.getParent(childId), rootId); @@ -136,7 +136,7 @@ public abstract class AbstractHierarchicalContainerTestBase if (!container.areChildrenAllowed(itemId)) { // If no children is allowed the item should have no children assertFalse(container.hasChildren(itemId)); - assertTrue(children == null || children.size() == 0); + assertTrue(children == null || children.isEmpty()); return; } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TablePropertyValueConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TablePropertyValueConverterTest.java index 09ace47f3d..836d4a9d89 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TablePropertyValueConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TablePropertyValueConverterTest.java @@ -44,8 +44,8 @@ public class TablePropertyValueConverterTest { @Test public void testRemovePropertyId() { Collection<Object> converters = table.getCurrentConverters(); - assertTrue("Set of converters was empty at the start.", - converters.size() > 0); + assertFalse("Set of converters was empty at the start.", + converters.isEmpty()); Object firstId = converters.iterator().next(); @@ -215,7 +215,7 @@ public class TablePropertyValueConverterTest { } }); Set<Object> converters = customTable.getCurrentConverters(); - assertTrue("Converter was not set.", converters.size() > 0); + assertFalse("Converter was not set.", converters.isEmpty()); } @Test diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java index c6fd03a7a3..6fc0377a74 100644 --- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java +++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java @@ -337,7 +337,7 @@ public class DataCommunicator<T> extends AbstractExtension { List<T> rowsToPush = fetchItemsWithRange(offset, limit); - if (!initial && !reset && rowsToPush.size() == 0) { + if (!initial && !reset && rowsToPush.isEmpty()) { triggerReset = true; } diff --git a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java index 23311dface..9086bf2cc2 100644 --- a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java @@ -515,7 +515,7 @@ public abstract class AbstractClientConnector Collection<Extension> extensions = connector.getExtensions(); boolean hasComponents = connector instanceof HasComponents; - boolean hasExtensions = extensions.size() > 0; + boolean hasExtensions = !extensions.isEmpty(); if (!hasComponents && !hasExtensions) { // If has neither component nor extensions, return immutable empty // list as iterable. diff --git a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java index b7e439244e..6db7d270d4 100644 --- a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java +++ b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java @@ -121,7 +121,7 @@ public abstract class AbstractErrorMessage implements ErrorMessage { break; } // if no message, combine the messages of all children - if (null == result && null != getCauses() && getCauses().size() > 0) { + if (null == result && null != getCauses() && !getCauses().isEmpty()) { StringBuilder sb = new StringBuilder(); for (ErrorMessage cause : getCauses()) { String childMessage = cause.getFormattedHtmlMessage(); diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java index fdcb578f01..8fe7892c39 100644 --- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java @@ -276,7 +276,7 @@ public class ComponentSizeValidator implements Serializable { clientJSON.append(",\"widthMsg\":\"").append(msg).append("\""); printServerError(msg, attributes, true, serverErrorStream); } - if (subErrors.size() > 0) { + if (!subErrors.isEmpty()) { serverErrorStream.println("Sub errors >>"); clientJSON.append(", \"subErrors\" : ["); boolean first = true; diff --git a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java index 3fef4926d3..b643fbb7a9 100644 --- a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java +++ b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java @@ -177,7 +177,7 @@ public class JsonPaintTarget implements PaintTarget { "Attempted to write to a closed PaintTarget."); } - if (openJsonTags.size() > 0) { + if (!openJsonTags.isEmpty()) { final JsonTag parent = openJsonTags.pop(); String lastTag = ""; diff --git a/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java b/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java index 22d25d8953..1a44c44cd2 100644 --- a/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java @@ -272,7 +272,7 @@ public class DragAndDropWrapper extends CustomComponent if (getDropHandler() != null) { getDropHandler().getAcceptCriterion().paint(target); } - if (receivers != null && receivers.size() > 0) { + if (receivers != null && !receivers.isEmpty()) { for (Iterator<Entry<String, ProxyReceiver>> it = receivers .entrySet().iterator(); it.hasNext();) { Entry<String, ProxyReceiver> entry = it.next(); diff --git a/server/src/main/java/com/vaadin/ui/GridLayout.java b/server/src/main/java/com/vaadin/ui/GridLayout.java index 03886dd0e8..27e1835b57 100644 --- a/server/src/main/java/com/vaadin/ui/GridLayout.java +++ b/server/src/main/java/com/vaadin/ui/GridLayout.java @@ -1315,7 +1315,7 @@ public class GridLayout extends AbstractLayout Element col = cols.get(column); Component child = null; - if (col.children().size() > 0) { + if (!col.children().isEmpty()) { Element childElement = col.child(0); child = designContext.readDesign(childElement); alignments.put(child, DesignAttributeHandler diff --git a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java index da5cafb9d6..4b82f0bdbe 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java @@ -591,7 +591,7 @@ public abstract class StaticSection<ROW extends StaticSection.StaticRow<?>> protected void readDesign(Element cellElement, DesignContext designContext) { if (!cellElement.hasAttr("plain-text")) { - if (cellElement.children().size() > 0 + if (!cellElement.children().isEmpty() && cellElement.child(0).tagName().contains("-")) { setComponent( designContext.readDesign(cellElement.child(0))); 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 aedd33618e..2caecda8f4 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java +++ b/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java @@ -91,7 +91,7 @@ public class FieldBinder implements Serializable { throw new FieldBindingException("Could not get field value", e); } } - if (unboundFields.size() > 0) { + if (!unboundFields.isEmpty()) { getLogger().severe( "Found unbound fields in component root :" + unboundFields); } diff --git a/server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java b/server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java index 59197cbc26..9503243fd9 100644 --- a/server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java +++ b/server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java @@ -119,7 +119,7 @@ public class FileDropTarget<T extends AbstractComponent> // Send upload URLs to the client if there are files to be // uploaded - if (urls.size() > 0) { + if (!urls.isEmpty()) { getRpcProxy(FileDropTargetClientRpc.class).sendUploadUrl(urls); } } diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java index 89c95ffeb8..0092363ebd 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java @@ -1,7 +1,7 @@ package com.vaadin.tests.server.componentcontainer; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -25,7 +25,7 @@ public class AddRemoveComponentTest { List<Class<? extends ComponentContainer>> containerClasses = VaadinClasses .getComponentContainersSupportingAddRemoveComponent(); - assertTrue(containerClasses.size() > 0); + assertFalse(containerClasses.isEmpty()); // No default constructor, special case containerClasses.remove(CustomLayout.class); diff --git a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java index 6bbd314761..fbc5767589 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java @@ -397,7 +397,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { } private void verifyValueChangeEvents() { - if (oldValues.size() > 0) { + if (!oldValues.isEmpty()) { assertTrue(oldValues.get(0).isEmpty()); assertEquals(values.size(), oldValues.size()); for (int i = 0; i < oldValues.size() - 1; i++) { diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java index d96793bf8e..6dafbfb812 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java @@ -297,7 +297,7 @@ public class AbstractSingleSelectTest { } private void verifyValueChanges() { - if (oldSelections.size() > 0) { + if (!oldSelections.isEmpty()) { assertEquals(null, oldSelections.get(0)); assertEquals(selectionChanges.size(), oldSelections.size()); for (int i = 0; i < oldSelections.size() - 1; i++) { diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/MenuBarElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/MenuBarElement.java index 8c54b0584c..3eb42b3aba 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/MenuBarElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/MenuBarElement.java @@ -94,7 +94,7 @@ public class MenuBarElement extends AbstractComponentElement { private WebElement getSelectedTopLevelItem() { List<WebElement> selectedItems = findElements( By.className("v-menubar-menuitem-selected")); - if (selectedItems.size() == 0) { + if (selectedItems.isEmpty()) { return null; } return selectedItems.get(0); diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java index 54c7291d51..7f6004a5af 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java @@ -32,8 +32,8 @@ public class TabSheetElement extends AbstractComponentContainerElement { // a locator that does not lead to selecting tabs from a contained inner // TabSheet (#13735) - protected org.openqa.selenium.By byTabCell = By - .xpath("./div/table/tbody/tr/td[contains(normalize-space(concat(' ', @class, ' '))," + protected org.openqa.selenium.By byTabCell = By.xpath( + "./div/table/tbody/tr/td[contains(normalize-space(concat(' ', @class, ' '))," + "normalize-space(' v-tabsheet-tabitem '))]"); private static org.openqa.selenium.By byCaption = By .className("v-captiontext"); @@ -109,14 +109,14 @@ public class TabSheetElement extends AbstractComponentContainerElement { private void openTab(WebElement tabCell) { // Open the tab by clicking its caption text if it exists. List<WebElement> tabCaptions = tabCell.findElements(byCaption); - if (tabCaptions.size() > 0) { + if (!tabCaptions.isEmpty()) { tabCaptions.get(0).click(); return; } // If no caption text was found, click the icon of the tab. List<WebElement> tabIcons = tabCell .findElements(By.className("v-icon")); - if (tabIcons.size() > 0) { + if (!tabIcons.isEmpty()) { tabIcons.get(0).click(); return; } @@ -201,7 +201,7 @@ public class TabSheetElement extends AbstractComponentContainerElement { */ private String getTabCaption(WebElement tabCell) { List<WebElement> captionElements = tabCell.findElements(byCaption); - if (captionElements.size() == 0) { + if (captionElements.isEmpty()) { return null; } else { return captionElements.get(0).getText(); diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeTableRowElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeTableRowElement.java index be6bf144a3..d702bacd08 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeTableRowElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeTableRowElement.java @@ -29,7 +29,7 @@ public class TreeTableRowElement extends TableRowElement { public void toggleExpanded() { List<WebElement> expandButtons = getWrappedElement() .findElements(By.className("v-treetable-treespacer")); - if (expandButtons.size() > 0) { + if (!expandButtons.isEmpty()) { expandButtons.get(0).click(); } } diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java index b92f410f1d..01e3beaa75 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java @@ -62,7 +62,7 @@ public class TwinColSelectElement extends AbstractSelectElement { } deselButton.click(); } - while (selectedOptions.getOptions().size() > 0) { + while (!selectedOptions.getOptions().isEmpty()) { selectedOptions.selectByIndex(0); deselButton.click(); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java b/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java index 55e97c5a31..5f6c9d5cb5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java @@ -92,7 +92,7 @@ public class KeyControl extends TestBase { public void valueChange(ValueChangeEvent event) { @SuppressWarnings("unchecked") Set<String> value = (Set<String>) table3.getValue(); - selected3.setValue(value.size() == 0 ? "No selected items" + selected3.setValue(value.isEmpty() ? "No selected items" : value + ": Total " + value.size() + " items"); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java b/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java index a920be534f..fd39ec377b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java @@ -109,7 +109,7 @@ public class LargeSelectionCausesNPE extends TestBase { // in multiselect mode, a Set of itemIds is returned, // in singleselect mode the itemId is returned directly Set<?> value = (Set<?>) event.getProperty().getValue(); - if (null == value || value.size() == 0) { + if (null == value || value.isEmpty()) { selected.setValue("No selection"); } else { selected.setValue("Selected: " + table.getValue()); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java index ca80a31e51..884f0a2d2b 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java @@ -36,7 +36,7 @@ public class CtrlShiftMultiselect extends TestBase { @SuppressWarnings("unchecked") // safe cast after instanceof check Set<Object> itemIds = (Set<Object>) tree.getValue(); - if (itemIds.size() == 0) { + if (itemIds.isEmpty()) { valueLbl.setValue("No selection"); } else { valueLbl.setValue(itemIds.toString()); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java index 85765384c0..af88e41c1f 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java @@ -36,7 +36,7 @@ public class ExpandCollapseTree extends TestBase { @SuppressWarnings("unchecked") // safe cast after instanceof check Set<Object> itemIds = (Set<Object>) tree.getValue(); - if (itemIds.size() == 0) { + if (itemIds.isEmpty()) { valueLbl.setValue("No selection"); } else { valueLbl.setValue(itemIds.toString()); diff --git a/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java index 689fe719e5..0db4875232 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.components; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.List; @@ -36,7 +37,7 @@ public abstract class HasValueRequiredIndicatorTest extends MultiBrowserTest { public void requiredIndicatorVisible() { openTestURL(); List<WebElement> layouts = findElements(By.className("vaadin-layout")); - assertTrue(layouts.size() > 0); + assertFalse(layouts.isEmpty()); layouts.stream().forEach(this::checkRequiredIndicator); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java index 356f544f2d..36367e4b66 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -170,7 +169,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { assertItemSuffices(20); List<WebElement> icons = getSelect() .findElements(By.cssSelector(".v-select-optiongroup .v-icon")); - assertTrue(icons.size() > 0); + assertFalse(icons.isEmpty()); for (int i = 0; i < icons.size(); i++) { assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), icons.get(i).getText().charAt(0)); @@ -219,8 +218,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { } private void assertSelected(String... expectedSelection) { - assertEquals(Arrays.asList(expectedSelection), - getSelect().getValue()); + assertEquals(Arrays.asList(expectedSelection), getSelect().getValue()); } @Override @@ -276,7 +274,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { List<String> optionsIcons = new ArrayList<>(); for (WebElement option : getSelect().getOptionElements()) { List<WebElement> images = option.findElements(By.tagName("img")); - if (images.size() > 0) { + if (!images.isEmpty()) { optionsIcons.add(images.get(0).getAttribute("src")); } else { optionsIcons.add(null); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java index db0ad112a6..b156ee0f3e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java @@ -68,7 +68,7 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { int col) { GridCellElement cell = grid.getHeaderCell(row, col); List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); - if (all.size() == 0) { + if (all.isEmpty()) { return null; } else if (all.size() == 1) { return all.get(0); @@ -106,7 +106,7 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { int col) { GridCellElement cell = grid.getFooterCell(row, col); List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); - if (all.size() == 0) { + if (all.isEmpty()) { return null; } else if (all.size() == 1) { return all.get(0); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java index 5febb3609b..b95cb5268d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.components.table; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertFalse; import java.util.List; @@ -24,8 +25,8 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -96,7 +97,7 @@ public class TableInIframeRowClickScrollJumpTest extends MultiBrowserTest { public void switchIntoIframe() { List<WebElement> frames = driver.findElements(By.tagName("iframe")); - assertThat("No frames was found", frames.size() > 0); + assertFalse("No frames was found", frames.isEmpty()); driver.switchTo().frame(frames.get(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java index 48f8e782c6..adaf019719 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.components.table; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -70,12 +71,12 @@ public class TableToggleColumnVisibilityTest extends MultiBrowserTest { assertTrue("Column header text should be custom", headerCell.getText().equalsIgnoreCase("Hello World")); - assertTrue("Column should have an icon", - headerCell.findElements(By.className("v-icon")).size() > 0); + assertFalse("Column should have an icon", + headerCell.findElements(By.className("v-icon")).isEmpty()); - assertTrue("Column should have alignment to the right", headerCell + assertFalse("Column should have alignment to the right", headerCell .findElements( By.className("v-table-caption-container-align-right")) - .size() > 0); + .isEmpty()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java index fb97542862..4ad1a9aeb3 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java @@ -104,7 +104,7 @@ public class TabSheetElementTabWithoutCaptionTest extends MultiBrowserTest { List<WebElement> openTabCaptionElements = tab .findElement(By.className("v-caption")) .findElements(By.className("v-captiontext")); - if (openTabCaptionElements.size() > 0) { + if (!openTabCaptionElements.isEmpty()) { String openTabCaption = openTabCaptionElements.get(0).getText(); assertEquals("Wrong tab is open.", caption, openTabCaption); } else { @@ -127,9 +127,9 @@ public class TabSheetElementTabWithoutCaptionTest extends MultiBrowserTest { boolean tabsOpen = false; for (int i = 0; i < tabs.size(); i++) { WebElement tab = tabs.get(i); - boolean isOpened = tab + boolean isOpened = !tab .findElements(By.className("v-tabsheet-tabitem-selected")) - .size() > 0; + .isEmpty(); if (isOpened) { tabsOpen = true; assertEquals("The wrong tab is open.", index, i); @@ -140,4 +140,4 @@ public class TabSheetElementTabWithoutCaptionTest extends MultiBrowserTest { + " should be open."); } } -}
\ No newline at end of file +} diff --git a/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java index 7865dd24ef..9f5330f538 100644 --- a/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java @@ -97,7 +97,7 @@ public class CalendarSmokeTest extends MultiBrowserTest { private WebElement getFirstDayWithEvents() { for (WebElement monthDay : getCalendar().getMonthDays()) { - if (getVisibleEvents(monthDay).size() > 0) { + if (!getVisibleEvents(monthDay).isEmpty()) { return monthDay; } } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java index c04104934b..3b3ab94e86 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -277,7 +277,7 @@ public abstract class AbstractTB3Test extends ParallelTest { parameters.add("restartApplication"); } - if (parameters.size() > 0) { + if (!parameters.isEmpty()) { url += "?" + StringUtils.join(parameters, "&"); } |