aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/main/java/com/vaadin/server/data/BackEndDataSource.java8
-rw-r--r--server/src/main/java/com/vaadin/server/data/DataCommunicator.java6
-rw-r--r--server/src/main/java/com/vaadin/server/data/DataSource.java14
-rw-r--r--server/src/main/java/com/vaadin/server/data/ListDataSource.java4
-rw-r--r--server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java2
-rw-r--r--server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java16
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractListingTest.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java16
-rw-r--r--uitest/src/main/java/com/vaadin/tests/data/DummyData.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java2
10 files changed, 42 insertions, 34 deletions
diff --git a/server/src/main/java/com/vaadin/server/data/BackEndDataSource.java b/server/src/main/java/com/vaadin/server/data/BackEndDataSource.java
index e0cfc8f48b..c792ebd23e 100644
--- a/server/src/main/java/com/vaadin/server/data/BackEndDataSource.java
+++ b/server/src/main/java/com/vaadin/server/data/BackEndDataSource.java
@@ -50,13 +50,13 @@ public class BackEndDataSource<T> extends AbstractDataSource<T> {
}
@Override
- public Stream<T> apply(Query t) {
- return request.apply(t);
+ public Stream<T> fetch(Query query) {
+ return request.apply(query);
}
@Override
- public int size(Query t) {
- return sizeCallback.apply(t);
+ public int size(Query query) {
+ return sizeCallback.apply(query);
}
/**
diff --git a/server/src/main/java/com/vaadin/server/data/DataCommunicator.java b/server/src/main/java/com/vaadin/server/data/DataCommunicator.java
index 5fc11bb15d..8238777c64 100644
--- a/server/src/main/java/com/vaadin/server/data/DataCommunicator.java
+++ b/server/src/main/java/com/vaadin/server/data/DataCommunicator.java
@@ -228,7 +228,7 @@ public class DataCommunicator<T> extends AbstractExtension {
if (initial || reset) {
int dataSourceSize;
if (getDataSource().isInMemory() && inMemoryFilter != null) {
- dataSourceSize = (int) getDataSource().apply(new Query())
+ dataSourceSize = (int) getDataSource().fetch(new Query())
.filter(inMemoryFilter).count();
} else {
dataSourceSize = getDataSource().size(new Query(filters));
@@ -244,7 +244,7 @@ public class DataCommunicator<T> extends AbstractExtension {
if (getDataSource().isInMemory()) {
// We can safely request all the data when in memory
- rowsToPush = getDataSource().apply(new Query());
+ rowsToPush = getDataSource().fetch(new Query());
if (inMemoryFilter != null) {
rowsToPush = rowsToPush.filter(inMemoryFilter);
}
@@ -254,7 +254,7 @@ public class DataCommunicator<T> extends AbstractExtension {
rowsToPush = rowsToPush.skip(offset).limit(limit);
} else {
Query query = new Query(offset, limit, backEndSorting, filters);
- rowsToPush = getDataSource().apply(query);
+ rowsToPush = getDataSource().fetch(query);
}
pushData(offset, rowsToPush);
}
diff --git a/server/src/main/java/com/vaadin/server/data/DataSource.java b/server/src/main/java/com/vaadin/server/data/DataSource.java
index f767f60cf0..c4042ecc11 100644
--- a/server/src/main/java/com/vaadin/server/data/DataSource.java
+++ b/server/src/main/java/com/vaadin/server/data/DataSource.java
@@ -18,7 +18,6 @@ package com.vaadin.server.data;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
-import java.util.function.Function;
import java.util.stream.Stream;
import com.vaadin.shared.Registration;
@@ -37,8 +36,7 @@ import com.vaadin.shared.Registration;
*
* @since 8.0
*/
-public interface DataSource<T>
- extends Function<Query, Stream<T>>, Serializable {
+public interface DataSource<T> extends Serializable {
/**
* Gets whether the DataSource content all available in memory or does it
@@ -58,6 +56,16 @@ public interface DataSource<T>
int size(Query t);
/**
+ * Fetches data from this DataSource using given {@code query}.
+ *
+ * @param query
+ * given query to request data
+ * @return the result of the query request: a stream of data objects, not
+ * {@code null}
+ */
+ Stream<T> fetch(Query query);
+
+ /**
* Refreshes all data based on currently available data in the underlying
* provider.
*/
diff --git a/server/src/main/java/com/vaadin/server/data/ListDataSource.java b/server/src/main/java/com/vaadin/server/data/ListDataSource.java
index 64b7c03cb1..1e2724dc5b 100644
--- a/server/src/main/java/com/vaadin/server/data/ListDataSource.java
+++ b/server/src/main/java/com/vaadin/server/data/ListDataSource.java
@@ -63,7 +63,7 @@ public class ListDataSource<T> extends AbstractDataSource<T> {
}
@Override
- public Stream<T> apply(Query query) {
+ public Stream<T> fetch(Query query) {
Stream<T> stream = backend.stream();
if (sortOrder != null) {
stream = stream.sorted(sortOrder);
@@ -117,7 +117,7 @@ public class ListDataSource<T> extends AbstractDataSource<T> {
* return the full size.
*/
@Override
- public int size(Query t) {
+ public int size(Query query) {
return backend.size();
}
diff --git a/server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java b/server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java
index 4898869743..187f8e0d77 100644
--- a/server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java
+++ b/server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java
@@ -31,7 +31,7 @@ public class AbstractDataSourceTest {
private static class TestDataSource extends AbstractDataSource<Object> {
@Override
- public Stream<Object> apply(Query t) {
+ public Stream<Object> fetch(Query t) {
return null;
}
diff --git a/server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java b/server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java
index a6dcc77474..a428858a42 100644
--- a/server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java
+++ b/server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java
@@ -29,7 +29,7 @@ public class ListDataSourceTest {
@Test
public void testListContainsAllData() {
List<StrBean> list = new LinkedList<>(data);
- dataSource.apply(new Query())
+ dataSource.fetch(new Query())
.forEach(str -> assertTrue(
"Data source contained values not in original data",
list.remove(str)));
@@ -42,7 +42,7 @@ public class ListDataSourceTest {
Comparator<StrBean> comp = Comparator.comparing(StrBean::getValue)
.thenComparing(StrBean::getRandomNumber)
.thenComparing(StrBean::getId);
- List<StrBean> list = dataSource.sortingBy(comp).apply(new Query())
+ List<StrBean> list = dataSource.sortingBy(comp).fetch(new Query())
.collect(Collectors.toList());
// First value in data is { Xyz, 10, 100 } which should be last in list
@@ -63,7 +63,7 @@ public class ListDataSourceTest {
public void testDefatulSortWithSpecifiedPostSort() {
Comparator<StrBean> comp = Comparator.comparing(StrBean::getValue)
.thenComparing(Comparator.comparing(StrBean::getId).reversed());
- List<StrBean> list = dataSource.sortingBy(comp).apply(new Query())
+ List<StrBean> list = dataSource.sortingBy(comp).fetch(new Query())
// The sort here should come e.g from a Component
.sorted(Comparator.comparing(StrBean::getRandomNumber))
.collect(Collectors.toList());
@@ -91,7 +91,7 @@ public class ListDataSourceTest {
@Test
public void testDefatulSortWithFunction() {
List<StrBean> list = dataSource.sortingBy(StrBean::getValue)
- .apply(new Query()).collect(Collectors.toList());
+ .fetch(new Query()).collect(Collectors.toList());
Assert.assertEquals("Sorted data and original data sizes don't match",
data.size(), list.size());
@@ -114,7 +114,7 @@ public class ListDataSourceTest {
data.set(0, bean);
dataSource.refreshAll();
- List<StrBean> list = dataSource.apply(query)
+ List<StrBean> list = dataSource.fetch(query)
.collect(Collectors.toList());
StrBean first = list.get(0);
Assert.assertEquals(bean.getValue(), first.getValue());
@@ -133,7 +133,7 @@ public class ListDataSourceTest {
bean.setValue("foo");
dataSource.refreshAll();
- List<StrBean> list = dataSource.apply(query)
+ List<StrBean> list = dataSource.fetch(query)
.collect(Collectors.toList());
StrBean first = list.get(0);
Assert.assertEquals("foo", first.getValue());
@@ -153,7 +153,7 @@ public class ListDataSourceTest {
.sortingBy(Comparator.comparing(StrBean::getId));
dSource.refreshAll();
- List<StrBean> list = dSource.apply(query).collect(Collectors.toList());
+ List<StrBean> list = dSource.fetch(query).collect(Collectors.toList());
StrBean first = list.get(0);
Assert.assertEquals(bean.getValue(), first.getValue());
Assert.assertEquals(bean.getRandomNumber(), first.getRandomNumber());
@@ -172,7 +172,7 @@ public class ListDataSourceTest {
data.add(0, bean);
dataSource.refreshAll();
- List<StrBean> list = dataSource.apply(query)
+ List<StrBean> list = dataSource.fetch(query)
.collect(Collectors.toList());
StrBean first = list.get(0);
Assert.assertEquals(bean.getValue(), first.getValue());
diff --git a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
index bbe0fd01aa..585dce1f5e 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
@@ -70,7 +70,7 @@ public class AbstractListingTest {
public void testSetItemsWithCollection() {
listing.setItems(items);
List<String> list = new LinkedList<>(items);
- listing.getDataSource().apply(new Query()).forEach(
+ listing.getDataSource().fetch(new Query()).forEach(
str -> Assert.assertTrue("Unexpected item in data source",
list.remove(str)));
Assert.assertTrue("Not all items from list were in data source",
@@ -80,7 +80,7 @@ public class AbstractListingTest {
@Test
public void testSetItemsWithVarargs() {
listing.setItems(ITEM_ARRAY);
- listing.getDataSource().apply(new Query()).forEach(
+ listing.getDataSource().fetch(new Query()).forEach(
str -> Assert.assertTrue("Unexpected item in data source",
items.remove(str)));
Assert.assertTrue("Not all items from list were in data source",
diff --git a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java
index cd2e8ad1f4..d78025bf4c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java
@@ -50,7 +50,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Add first", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
list.add(0, "first");
dataSource = new ListDataSource<>(list);
@@ -59,7 +59,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Add middle", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
list.add(list.size() / 2, "middle");
dataSource = new ListDataSource<>(list);
@@ -68,7 +68,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Add last", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
list.add("last");
dataSource = new ListDataSource<>(list);
@@ -77,7 +77,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Swap", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
Collections.swap(list, 0, list.size() - 1);
dataSource = new ListDataSource<>(list);
@@ -87,7 +87,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Remove first", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
list.remove(0);
@@ -98,7 +98,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Remove middle", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
list.remove(list.size() / 2);
dataSource = new ListDataSource<>(list);
@@ -107,7 +107,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
}));
addComponent(new Button("Remove last", event -> {
- List<String> list = dataSource.apply(null)
+ List<String> list = dataSource.fetch(null)
.collect(Collectors.toList());
list.remove(list.size() - 1);
@@ -121,7 +121,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog {
private void logContainer() {
StringBuilder b = new StringBuilder();
- List<String> list = dataSource.apply(null).collect(Collectors.toList());
+ List<String> list = dataSource.fetch(null).collect(Collectors.toList());
for (int i = 0; i < list.size(); i++) {
Object id = list.get(i);
if (i != 0) {
diff --git a/uitest/src/main/java/com/vaadin/tests/data/DummyData.java b/uitest/src/main/java/com/vaadin/tests/data/DummyData.java
index 8b4083d834..917eb39bbd 100644
--- a/uitest/src/main/java/com/vaadin/tests/data/DummyData.java
+++ b/uitest/src/main/java/com/vaadin/tests/data/DummyData.java
@@ -34,9 +34,9 @@ public class DummyData extends AbstractTestUIWithLog {
}
@Override
- public Stream<String> apply(Query query) {
+ public Stream<String> fetch(Query query) {
log("Backend request #" + (count++));
- return super.apply(query);
+ return super.fetch(query);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java b/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java
index 5aee3a2f15..910265696f 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java
@@ -53,7 +53,7 @@ public class MovingComponentsWhileOldParentInvisible extends TestBase {
});
componentContainerSelect.setValue(componentContainerSelect
- .getDataSource().apply(new Query()).iterator().next());
+ .getDataSource().fetch(new Query()).iterator().next());
Button but1 = new Button("Move in and out of component container",
new Button.ClickListener() {