aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/data/provider
diff options
context:
space:
mode:
authorDenis <denis@vaadin.com>2017-01-25 09:36:29 +0200
committerGitHub <noreply@github.com>2017-01-25 09:36:29 +0200
commit6c6161caeb8d4524aba11fa7976366981e090e85 (patch)
tree3bac170fd710a0611f02ad752a23ebc1946849ef /server/src/main/java/com/vaadin/data/provider
parentdcb8271b50b9d76dd9c56af1f1621ed39072b229 (diff)
downloadvaadin-framework-6c6161caeb8d4524aba11fa7976366981e090e85.tar.gz
vaadin-framework-6c6161caeb8d4524aba11fa7976366981e090e85.zip
Use non-Generic SortOrder in Query. (#8239)
* Use non-Generic SortOrder in Query. Fixes #8215
Diffstat (limited to 'server/src/main/java/com/vaadin/data/provider')
-rw-r--r--server/src/main/java/com/vaadin/data/provider/AbstractBackEndDataProvider.java6
-rw-r--r--server/src/main/java/com/vaadin/data/provider/BackEndDataProvider.java6
-rw-r--r--server/src/main/java/com/vaadin/data/provider/DataCommunicator.java6
-rw-r--r--server/src/main/java/com/vaadin/data/provider/Query.java6
-rw-r--r--server/src/main/java/com/vaadin/data/provider/QuerySortOrder.java48
-rw-r--r--server/src/main/java/com/vaadin/data/provider/Sort.java24
-rw-r--r--server/src/main/java/com/vaadin/data/provider/SortOrder.java1
7 files changed, 71 insertions, 26 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/AbstractBackEndDataProvider.java b/server/src/main/java/com/vaadin/data/provider/AbstractBackEndDataProvider.java
index 8da5d7a726..9b08bb8c1d 100644
--- a/server/src/main/java/com/vaadin/data/provider/AbstractBackEndDataProvider.java
+++ b/server/src/main/java/com/vaadin/data/provider/AbstractBackEndDataProvider.java
@@ -33,7 +33,7 @@ import java.util.stream.Stream;
public abstract class AbstractBackEndDataProvider<T, F> extends
AbstractDataProvider<T, F> implements BackEndDataProvider<T, F> {
- private List<SortOrder<String>> sortOrders = new ArrayList<>();
+ private List<QuerySortOrder> sortOrders = new ArrayList<>();
private Query<T, F> mixInSortOrders(Query<T, F> query) {
if (sortOrders.isEmpty()) {
@@ -43,7 +43,7 @@ public abstract class AbstractBackEndDataProvider<T, F> extends
Set<String> sortedPropertyNames = query.getSortOrders().stream()
.map(SortOrder::getSorted).collect(Collectors.toSet());
- List<SortOrder<String>> combinedSortOrders = Stream
+ List<QuerySortOrder> combinedSortOrders = Stream
.concat(query.getSortOrders().stream(),
sortOrders.stream()
.filter(order -> !sortedPropertyNames
@@ -86,7 +86,7 @@ public abstract class AbstractBackEndDataProvider<T, F> extends
protected abstract int sizeInBackEnd(Query<T, F> query);
@Override
- public void setSortOrders(List<SortOrder<String>> sortOrders) {
+ public void setSortOrders(List<QuerySortOrder> sortOrders) {
this.sortOrders = Objects.requireNonNull(sortOrders,
"Sort orders cannot be null");
refreshAll();
diff --git a/server/src/main/java/com/vaadin/data/provider/BackEndDataProvider.java b/server/src/main/java/com/vaadin/data/provider/BackEndDataProvider.java
index f20b22fa17..36d875a21a 100644
--- a/server/src/main/java/com/vaadin/data/provider/BackEndDataProvider.java
+++ b/server/src/main/java/com/vaadin/data/provider/BackEndDataProvider.java
@@ -37,12 +37,12 @@ public interface BackEndDataProvider<T, F> extends DataProvider<T, F> {
* sorting is also used to determine the ordering of items that are
* considered equal by the sorting defined in the query.
*
- * @see #setSortOrder(SortOrder)
+ * @see #setSortOrder(QuerySortOrder)
*
* @param sortOrders
* a list of sort orders to set, not <code>null</code>
*/
- void setSortOrders(List<SortOrder<String>> sortOrders);
+ void setSortOrders(List<QuerySortOrder> sortOrders);
/**
* Sets a single sort order to use as the default sorting for this data
@@ -59,7 +59,7 @@ public interface BackEndDataProvider<T, F> extends DataProvider<T, F> {
* a sort order to set, or <code>null</code> to clear any
* previously set sort orders
*/
- default void setSortOrder(SortOrder<String> sortOrder) {
+ default void setSortOrder(QuerySortOrder sortOrder) {
if (sortOrder == null) {
setSortOrders(Collections.emptyList());
} else {
diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
index 12fd323bc1..7b909b831d 100644
--- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
+++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
@@ -201,7 +201,7 @@ public class DataCommunicator<T, F> extends AbstractExtension {
private F filter;
private Comparator<T> inMemorySorting;
- private final List<SortOrder<String>> backEndSorting = new ArrayList<>();
+ private final List<QuerySortOrder> backEndSorting = new ArrayList<>();
private final DataCommunicatorClientRpc rpc;
public DataCommunicator() {
@@ -421,12 +421,12 @@ public class DataCommunicator<T, F> extends AbstractExtension {
}
/**
- * Sets the {@link SortOrder}s to use with backend sorting.
+ * Sets the {@link QuerySortOrder}s to use with backend sorting.
*
* @param sortOrder
* list of sort order information to pass to a query
*/
- public void setBackEndSorting(List<SortOrder<String>> sortOrder) {
+ public void setBackEndSorting(List<QuerySortOrder> sortOrder) {
backEndSorting.clear();
backEndSorting.addAll(sortOrder);
reset();
diff --git a/server/src/main/java/com/vaadin/data/provider/Query.java b/server/src/main/java/com/vaadin/data/provider/Query.java
index a4e0197d83..abf905658c 100644
--- a/server/src/main/java/com/vaadin/data/provider/Query.java
+++ b/server/src/main/java/com/vaadin/data/provider/Query.java
@@ -36,7 +36,7 @@ public class Query<T, F> implements Serializable {
private final int offset;
private final int limit;
- private final List<SortOrder<String>> sortOrders;
+ private final List<QuerySortOrder> sortOrders;
private final Comparator<T> inMemorySorting;
private final F filter;
@@ -83,7 +83,7 @@ public class Query<T, F> implements Serializable {
* @param filter
* filtering for fetching; can be null
*/
- public Query(int offset, int limit, List<SortOrder<String>> sortOrders,
+ public Query(int offset, int limit, List<QuerySortOrder> sortOrders,
Comparator<T> inMemorySorting, F filter) {
this.offset = offset;
this.limit = limit;
@@ -123,7 +123,7 @@ public class Query<T, F> implements Serializable {
*
* @return list of sort orders
*/
- public List<SortOrder<String>> getSortOrders() {
+ public List<QuerySortOrder> getSortOrders() {
return sortOrders;
}
diff --git a/server/src/main/java/com/vaadin/data/provider/QuerySortOrder.java b/server/src/main/java/com/vaadin/data/provider/QuerySortOrder.java
new file mode 100644
index 0000000000..ca8d743fae
--- /dev/null
+++ b/server/src/main/java/com/vaadin/data/provider/QuerySortOrder.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.data.provider;
+
+import com.vaadin.shared.data.sort.SortDirection;
+
+/**
+ * Sorting information for {@link Query}.
+ *
+ * @see Query
+ */
+public class QuerySortOrder extends SortOrder<String> {
+
+ /**
+ * Constructs sorting information for usage in a {@link Query}.
+ *
+ * @param sorted
+ * sorting information, usually field id
+ * @param direction
+ * sorting direction
+ */
+ public QuerySortOrder(String sorted, SortDirection direction) {
+ super(sorted, direction);
+ }
+
+ /**
+ * Gets sorting information.
+ *
+ * @return sorting entity, usually field id
+ */
+ @Override
+ public String getSorted() {
+ return super.getSorted();
+ }
+}
diff --git a/server/src/main/java/com/vaadin/data/provider/Sort.java b/server/src/main/java/com/vaadin/data/provider/Sort.java
index 303ee05f74..0655c7d0e4 100644
--- a/server/src/main/java/com/vaadin/data/provider/Sort.java
+++ b/server/src/main/java/com/vaadin/data/provider/Sort.java
@@ -35,16 +35,14 @@ public abstract class Sort implements Serializable {
* lists. When the sort order is ready to be passed on, calling
* {@link #build()} will create the list of sort orders
*
- * @param <S>
- * sort order data type
*
* @see Sort
* @see Sort#asc(Object)
* @see Sort#desc(Object)
* @see #build()
*/
- public static class SortBuilder<S> implements Serializable {
- private List<SortOrder<S>> sortOrder = new ArrayList<>();
+ public static class SortBuilder implements Serializable {
+ private List<QuerySortOrder> sortOrder = new ArrayList<>();
/**
* Constructs an empty SortBuilder.
@@ -59,7 +57,7 @@ public abstract class Sort implements Serializable {
* the object to sort by
* @return this sort builder
*/
- public SortBuilder<S> thenAsc(S by) {
+ public SortBuilder thenAsc(String by) {
return append(by, SortDirection.ASCENDING);
}
@@ -70,7 +68,7 @@ public abstract class Sort implements Serializable {
* the object to sort by
* @return this sort builder
*/
- public SortBuilder<S> thenDesc(S by) {
+ public SortBuilder thenDesc(String by) {
return append(by, SortDirection.DESCENDING);
}
@@ -84,8 +82,8 @@ public abstract class Sort implements Serializable {
*
* @return this sort builder
*/
- protected SortBuilder<S> append(S by, SortDirection direction) {
- sortOrder.add(new SortOrder<>(by, direction));
+ protected SortBuilder append(String by, SortDirection direction) {
+ sortOrder.add(new QuerySortOrder(by, direction));
return this;
}
@@ -95,7 +93,7 @@ public abstract class Sort implements Serializable {
*
* @return the unmodifiable sort order list
*/
- public List<SortOrder<S>> build() {
+ public List<QuerySortOrder> build() {
return Collections.unmodifiableList(sortOrder);
}
}
@@ -111,8 +109,8 @@ public abstract class Sort implements Serializable {
*
* @return the sort builder
*/
- public static <S> SortBuilder<S> asc(S by) {
- return new SortBuilder<S>().thenAsc(by);
+ public static SortBuilder asc(String by) {
+ return new SortBuilder().thenAsc(by);
}
/**
@@ -126,7 +124,7 @@ public abstract class Sort implements Serializable {
*
* @return the sort builder
*/
- public static <S> SortBuilder<S> desc(S by) {
- return new SortBuilder<S>().thenDesc(by);
+ public static SortBuilder desc(String by) {
+ return new SortBuilder().thenDesc(by);
}
}
diff --git a/server/src/main/java/com/vaadin/data/provider/SortOrder.java b/server/src/main/java/com/vaadin/data/provider/SortOrder.java
index 34e560e2d1..cb6a62668a 100644
--- a/server/src/main/java/com/vaadin/data/provider/SortOrder.java
+++ b/server/src/main/java/com/vaadin/data/provider/SortOrder.java
@@ -22,7 +22,6 @@ import com.vaadin.shared.data.sort.SortDirection;
/**
* Sorting information for one field.
*
- * @see Query
* @param <T>
* the type of the sorting information, usually a String (field id)
* or a {@link java.util.Comparator}.