diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-11-29 11:20:03 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-11-29 10:54:04 +0000 |
commit | 5ab990325f370d767a5ad76b016a852fb2b5330c (patch) | |
tree | 26fa395af986066d64d416b4ff8e96d2a81fb20d /server/src/main/java/com | |
parent | b8e84da2e2dc4bcaed40d169c40a97f3d11e0648 (diff) | |
download | vaadin-framework-5ab990325f370d767a5ad76b016a852fb2b5330c.tar.gz vaadin-framework-5ab990325f370d767a5ad76b016a852fb2b5330c.zip |
Remove ItemFilter from ComboBox
Change-Id: I3564c3afc00b2fb8849e46688c99b418e76ba937
Diffstat (limited to 'server/src/main/java/com')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 55 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ItemCaptionGenerator.java | 2 |
2 files changed, 8 insertions, 49 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index b958ca9c32..9034fabf11 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.function.BiFunction; import java.util.function.Consumer; import org.jsoup.nodes.Element; @@ -113,19 +112,6 @@ public class ComboBox<T> extends AbstractSingleSelect<T> } } - /** - * Filter can be used to customize the filtering of items based on user - * input. - * - * @see ComboBox#setFilter(ItemFilter) - * @param <T> - * item type in the combo box - */ - @FunctionalInterface - public interface ItemFilter<T> - extends BiFunction<String, T, Boolean>, Serializable { - } - private ComboBoxServerRpc rpc = new ComboBoxServerRpc() { @Override public void createNewItem(String itemValue) { @@ -149,15 +135,10 @@ public class ComboBox<T> extends AbstractSingleSelect<T> private StyleGenerator<T> itemStyleGenerator = item -> null; - private ItemFilter<T> filter = (filterText, item) -> { - if (filterText == null) { - return true; - } else { - return getItemCaptionGenerator().apply(item) + private final SerializableBiPredicate<String, T> defaultFilterMethod = ( + text, item) -> getItemCaptionGenerator().apply(item) .toLowerCase(getLocale()) - .contains(filterText.toLowerCase(getLocale())); - } - }; + .contains(text.toLowerCase(getLocale())); /** * Constructs an empty combo box without a caption. The content of the combo @@ -237,16 +218,16 @@ public class ComboBox<T> extends AbstractSingleSelect<T> @Override public void setItems(Collection<T> items) { DataProvider<T, String> provider = DataProvider.create(items) - .convertFilter(filterText -> item -> getFilter() - .apply(filterText, item)); + .convertFilter(filterText -> item -> defaultFilterMethod + .test(filterText, item)); setDataProvider(provider); } @Override public void setItems(@SuppressWarnings("unchecked") T... items) { DataProvider<T, String> provider = DataProvider.create(items) - .convertFilter(filterText -> item -> getFilter() - .apply(filterText, item)); + .convertFilter(filterText -> item -> defaultFilterMethod + .test(filterText, item)); setDataProvider(provider); } @@ -543,28 +524,6 @@ public class ComboBox<T> extends AbstractSingleSelect<T> // HasValue methods delegated to the selection model - /** - * Returns the filter used to customize the list based on user input. - * - * @return the current filter, not null - */ - public ItemFilter<T> getFilter() { - return filter; - } - - /** - * Sets the filter used to customize the list based on user input. The - * default filter checks case-insensitively that the input string is - * contained in the item caption. - * - * @param filter - * the filter function to use, not null - */ - public void setFilter(ItemFilter<T> filter) { - Objects.requireNonNull(filter, "Item filter must not be null"); - this.filter = filter; - } - @Override public Registration addValueChangeListener( HasValue.ValueChangeListener<T> listener) { diff --git a/server/src/main/java/com/vaadin/ui/ItemCaptionGenerator.java b/server/src/main/java/com/vaadin/ui/ItemCaptionGenerator.java index 0a57d901e9..c608eaf857 100644 --- a/server/src/main/java/com/vaadin/ui/ItemCaptionGenerator.java +++ b/server/src/main/java/com/vaadin/ui/ItemCaptionGenerator.java @@ -36,7 +36,7 @@ public interface ItemCaptionGenerator<T> * * @param item * the item to get caption for - * @return the caption of the item + * @return the caption of the item; not {@code null} */ @Override String apply(T item); |