diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-12 10:46:06 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-12 11:46:06 +0300 |
commit | c147b5d85bca3ddf30d9adbcd268066165889f37 (patch) | |
tree | 18d73bda278618004ec4a28ee62af7eb7edbeb98 /compatibility-server/src | |
parent | 13d406a7086cc1546eac3fa86f6263bfb436de85 (diff) | |
download | vaadin-framework-c147b5d85bca3ddf30d9adbcd268066165889f37.tar.gz vaadin-framework-c147b5d85bca3ddf30d9adbcd268066165889f37.zip |
Use Collection.isEmpty() (#10172)
Diffstat (limited to 'compatibility-server/src')
8 files changed, 15 insertions, 15 deletions
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 |