@@ -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); | |||
} |
@@ -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) { |
@@ -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); | |||
} |
@@ -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); |
@@ -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 { |
@@ -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. |
@@ -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); | |||
}-*/; |
@@ -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('.') |
@@ -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; | |||
} |
@@ -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); |
@@ -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); | |||
} | |||
} |
@@ -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; |
@@ -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)); | |||
} | |||
} |
@@ -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() |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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) { |
@@ -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(); |
@@ -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())); |
@@ -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() |
@@ -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; |
@@ -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; | |||
} |
@@ -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; |
@@ -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; |
@@ -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); |
@@ -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( |
@@ -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; |
@@ -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; |
@@ -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; | |||
} |
@@ -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 |
@@ -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; | |||
} | |||
@@ -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. |
@@ -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(); |
@@ -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; |
@@ -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 = ""; |
@@ -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(); |
@@ -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 |
@@ -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))); |
@@ -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); | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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); |
@@ -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++) { |
@@ -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++) { |
@@ -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); |
@@ -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(); |
@@ -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(); | |||
} | |||
} |
@@ -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(); | |||
} |
@@ -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"); | |||
} | |||
}); |
@@ -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()); |
@@ -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()); |
@@ -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()); |
@@ -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); | |||
} | |||
@@ -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); |
@@ -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); |
@@ -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)); | |||
} | |||
@@ -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()); | |||
} | |||
} |
@@ -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."); | |||
} | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -277,7 +277,7 @@ public abstract class AbstractTB3Test extends ParallelTest { | |||
parameters.add("restartApplication"); | |||
} | |||
if (parameters.size() > 0) { | |||
if (!parameters.isEmpty()) { | |||
url += "?" + StringUtils.join(parameters, "&"); | |||
} | |||