diff options
author | Denis Anisimov <denis@vaadin.com> | 2016-10-03 09:44:17 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-10-03 09:07:17 +0000 |
commit | 7c18c3d086142c46772e7555f07c053d1b293171 (patch) | |
tree | 518b9695c459206b6acd4aefda5b9a87bb43e806 /server/src/main | |
parent | 43bb825f0e7fbaa3a1382f85c9b2f6f6c4fe3ac4 (diff) | |
download | vaadin-framework-7c18c3d086142c46772e7555f07c053d1b293171.tar.gz vaadin-framework-7c18c3d086142c46772e7555f07c053d1b293171.zip |
Do not derive DataSource from Function and replace apply method #307.
Change-Id: Ic0587e75c9a50c802a64673b1db0b8828b37889c
Diffstat (limited to 'server/src/main')
4 files changed, 20 insertions, 12 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(); } |