Skip to content

Commit 8ec5c0f

Browse files
authored
refactor!: remove or hide deprecated setItems and getDataProvider (#4603)
1 parent c083891 commit 8ec5c0f

File tree

6 files changed

+11
-36
lines changed

6 files changed

+11
-36
lines changed

vaadin-checkbox-flow-parent/vaadin-checkbox-flow-integration-tests/src/main/java/com/vaadin/flow/component/checkbox/tests/RefreshDataProviderPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public RefreshDataProviderPage() {
3434
group.setId("group");
3535

3636
List<String> items = new LinkedList<>(Arrays.asList("foo", "bar"));
37-
group.setItems(new ListDataProvider<>(items));
37+
var listDataView = group.setItems(new ListDataProvider<>(items));
3838

3939
NativeButton button = new NativeButton("Update items", e -> {
4040
items.add("baz");
4141
items.remove(0);
42-
group.getDataProvider().refreshAll();
42+
listDataView.refreshAll();
4343
});
4444

4545
button.setId("reset");

vaadin-checkbox-flow-parent/vaadin-checkbox-flow/src/main/java/com/vaadin/flow/component/checkbox/CheckboxGroup.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,6 @@ public T getItem() {
320320
}
321321
}
322322

323-
/**
324-
* {@inheritDoc}
325-
*
326-
* @deprecated Because the stream is collected to a list anyway, use
327-
* {@link HasListDataView#setItems(Collection)} instead.
328-
*/
329-
@Deprecated
330-
public void setItems(Stream<T> streamOfItems) {
331-
setItems(DataProvider.fromStream(streamOfItems));
332-
}
333-
334323
private void setDataProvider(DataProvider<T, ?> dataProvider) {
335324
this.dataProvider.set(dataProvider);
336325
DataViewUtils.removeComponentFilterAndSortComparator(this);
@@ -402,11 +391,8 @@ public Registration addSelectionListener(
402391
* Gets the data provider.
403392
*
404393
* @return the data provider, not {@code null}
405-
* @deprecated use {@link #getListDataView()} or
406-
* {@link #getGenericDataView()} instead
407394
*/
408-
@Deprecated
409-
public DataProvider<T, ?> getDataProvider() {
395+
private DataProvider<T, ?> getDataProvider() {
410396
// dataProvider reference won't have been initialized before
411397
// calling from CheckboxGroup constructor
412398
return Optional.ofNullable(dataProvider).map(AtomicReference::get)

vaadin-checkbox-flow-parent/vaadin-checkbox-flow/src/test/java/com/vaadin/flow/component/checkbox/tests/CheckboxGroupTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public void singleDataRefreshEvent() {
256256

257257
item1.setLabel("etc");
258258
item2.setLabel("opt");
259-
checkboxGroup.getDataProvider().refreshItem(item1);
259+
checkboxGroup.getListDataView().refreshItem(item1);
260260
assertCheckboxLabels(checkboxGroup, "etc", "bar");
261261

262262
}
@@ -277,7 +277,7 @@ public void singleDataRefreshEvent_overrideDataProviderGetId() {
277277

278278
item1.setLabel("etc");
279279
item2.setLabel("opt");
280-
checkboxGroup.getDataProvider().refreshItem(new Wrapper(1));
280+
checkboxGroup.getListDataView().refreshItem(new Wrapper(1));
281281
assertCheckboxLabels(checkboxGroup, "etc", "bar");
282282

283283
}
@@ -298,7 +298,7 @@ public void allDataRefreshEvent() {
298298

299299
item1.setLabel("etc");
300300
item2.setLabel("opt");
301-
checkboxGroup.getDataProvider().refreshAll();
301+
checkboxGroup.getListDataView().refreshAll();
302302
assertCheckboxLabels(checkboxGroup, "etc", "opt");
303303

304304
}

vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/main/java/com/vaadin/flow/component/combobox/test/ComboBoxPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private void createWithRequestsSpyDataProvider() {
153153
private void createWithValueChangeListener() {
154154
ComboBox<Title> titles = new ComboBox<>();
155155

156-
titles.setItems(Stream.of(Title.values()));
156+
titles.setItems(Title.values());
157157

158158
titles.setId("titles");
159159
selectedTitle.setId("selected-titles");
@@ -164,7 +164,7 @@ private void createWithValueChangeListener() {
164164
private void createWithPresetValue() {
165165
ComboBox<Title> titles = new ComboBox<>();
166166

167-
titles.setItems(Stream.of(Title.values()));
167+
titles.setItems(Title.values());
168168
titles.setValue(Title.MRS);
169169

170170
titles.setId("titles-with-preset-value");

vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/main/java/com/vaadin/flow/component/combobox/test/PreSelectedValuePage.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.vaadin.flow.component.combobox.test;
1717

18+
import java.util.stream.Collectors;
1819
import java.util.stream.IntStream;
1920

2021
import com.vaadin.flow.component.combobox.ComboBox;
@@ -29,7 +30,8 @@ public class PreSelectedValuePage extends Div {
2930

3031
public PreSelectedValuePage() {
3132
ComboBox<String> comboBox = new ComboBox<>();
32-
comboBox.setItems(IntStream.range(0, 20).mapToObj(i -> "Item " + i));
33+
comboBox.setItems(IntStream.range(0, 20).mapToObj(i -> "Item " + i)
34+
.collect(Collectors.toList()));
3335
comboBox.setValue(PRE_SELECTED_VALUE);
3436
comboBox.setId("combo");
3537

vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBoxBase.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,6 @@ public ComboBoxListDataView<TItem> setItems(
669669
return dataController.setItems(dataProvider);
670670
}
671671

672-
/**
673-
* {@inheritDoc}
674-
*
675-
* @deprecated Because the stream is collected to a list anyway, use
676-
* {@link #setItems(Collection)} or
677-
* {@link #setItems(CallbackDataProvider.FetchCallback)}
678-
* instead.
679-
*/
680-
@Deprecated
681-
public void setItems(Stream<TItem> streamOfItems) {
682-
setItems(DataProvider.fromStream(streamOfItems));
683-
}
684-
685672
// ****************************************************
686673
// Lazy data view implementation
687674
// ****************************************************

0 commit comments

Comments
 (0)