本文整理了Java中com.vaadin.data.provider.Query.getLimit
方法的一些代码示例,展示了Query.getLimit
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getLimit
方法的具体详情如下:
包路径:com.vaadin.data.provider.Query
类名称:Query
方法名:getLimit
[英]Gets the limit of items to fetch. The limit is only used when fetching items, but not when counting the number of available items.
Note: It is possible that offset + limit > item count
[中]获取要获取的项的限制。该限制仅在获取项目时使用,但在计算可用项目的数量时不使用。
注意:有可能是偏移+限制>项目计数
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public Stream<T> fetch(Query<T, SerializablePredicate<T>> query) {
Stream<T> stream = getFilteredStream(query);
Optional<Comparator<T>> comparing = Stream
.of(query.getInMemorySorting(), sortOrder)
.filter(c -> c != null)
.reduce((c1, c2) -> c1.thenComparing(c2));
if (comparing.isPresent()) {
stream = stream.sorted(comparing.get());
}
return stream.skip(query.getOffset()).limit(query.getLimit());
}
代码示例来源:origin: com.vaadin/vaadin-server
private Query<T, F> mixInSortOrders(Query<T, F> query) {
if (sortOrders.isEmpty()) {
return query;
}
Set<String> sortedPropertyNames = query.getSortOrders().stream()
.map(SortOrder::getSorted).collect(Collectors.toSet());
List<QuerySortOrder> combinedSortOrders = Stream
.concat(query.getSortOrders().stream(),
sortOrders.stream()
.filter(order -> !sortedPropertyNames
.contains(order.getSorted())))
.collect(Collectors.toList());
return new Query<>(query.getOffset(), query.getLimit(),
combinedSortOrders, query.getInMemorySorting(),
query.getFilter().orElse(null));
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public Stream<T> fetch(Query<T, C> t) {
if (t instanceof HierarchicalQuery<?, ?>) {
return dataProvider.fetch(new HierarchicalQuery<>(
t.getOffset(), t.getLimit(), t.getSortOrders(),
t.getInMemorySorting(), getFilter(t),
((HierarchicalQuery<T, C>) t).getParent()));
}
throw new IllegalArgumentException(
"Hierarchical data provider doesn't support non-hierarchical queries");
}
};
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public int size(Query<T, C> t) {
if (t instanceof HierarchicalQuery<?, ?>) {
return dataProvider.size(new HierarchicalQuery<>(
t.getOffset(), t.getLimit(), t.getSortOrders(),
t.getInMemorySorting(), getFilter(t),
((HierarchicalQuery<T, C>) t).getParent()));
}
throw new IllegalArgumentException(
"Hierarchical data provider doesn't support non-hierarchical queries");
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Sets a CallbackDataProvider using the given fetch items callback and a
* size callback.
* <p>
* This method is a shorthand for making a {@link CallbackDataProvider} that
* handles a partial {@link com.vaadin.data.provider.Query Query} object.
*
* @param fetchItems
* a callback for fetching items
* @param sizeCallback
* a callback for getting the count of items
*
* @see CallbackDataProvider
* @see #setDataProvider(DataProvider)
*/
public void setDataProvider(FetchItemsCallback<T> fetchItems,
SerializableToIntFunction<String> sizeCallback) {
setDataProvider(new CallbackDataProvider<>(
q -> fetchItems.fetchItems(q.getFilter().orElse(""),
q.getOffset(), q.getLimit()),
q -> sizeCallback.applyAsInt(q.getFilter().orElse(""))));
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public int size(Query<T, F> t) {
return dataProvider.size(new Query<>(t.getOffset(), t.getLimit(),
t.getSortOrders(), t.getInMemorySorting(), getFilter(t)));
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public Stream<T> fetch(Query<T, F> t) {
return dataProvider.fetch(new Query<>(t.getOffset(), t.getLimit(),
t.getSortOrders(), t.getInMemorySorting(), getFilter(t)));
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Sets a CallbackDataProvider using the given fetch items callback and a
* size callback.
* <p>
* This method is a shorthand for making a {@link CallbackDataProvider} that
* handles a partial {@link Query} object.
*
* @param fetchItems
* a callback for fetching items
* @param sizeCallback
* a callback for getting the count of items
*
* @see CallbackDataProvider
* @see #setDataProvider(DataProvider)
*/
public void setDataProvider(FetchItemsCallback<T> fetchItems,
SerializableSupplier<Integer> sizeCallback) {
internalSetDataProvider(
new CallbackDataProvider<>(
q -> fetchItems.fetchItems(q.getSortOrders(),
q.getOffset(), q.getLimit()),
q -> sizeCallback.get()));
}
代码示例来源:origin: com.haulmont.cuba/cuba-web
@Override
public Stream<T> fetch(Query<T, SerializablePredicate<T>> query) {
if (dataGridItems.getState() == BindingState.INACTIVE) {
return Stream.empty();
}
return dataGridItems.getItems()
.skip(query.getOffset())
.limit(query.getLimit());
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
protected Stream<ITEM> fetchFromBackEnd(Query<ITEM, QueryFilter> query) {
getDataSource().setDataProviderQuery(query);
if (query.getLimit() == Integer.MAX_VALUE) {
return getAllItems().stream();
}
return getItemsByIndex(query.getOffset(), query.getLimit()).stream();
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
protected Stream<ITEM> fetchFromBackEnd(Query<ITEM, QueryFilter> query) {
return getDataProvider().load(getConfiguration(query), query.getOffset(), query.getLimit());
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
if (query.getLimit() < Integer.MAX_VALUE) {
q.limit(query.getLimit());
q.offset(query.getOffset());
代码示例来源:origin: jpos/jPOS-EE
public DataProvider getParentDataProvider() {
Map<String,Boolean> orders = new HashMap<>();
DataProvider dataProvider = DataProvider.fromCallbacks(
(CallbackDataProvider.FetchCallback) query -> {
int offset = query.getOffset();
int limit = query.getLimit();
Iterator it = query.getSortOrders().iterator();
while (it.hasNext()) {
QuerySortOrder order = (QuerySortOrder) it.next();
orders.put(order.getSorted(),order.getDirection() == SortDirection.DESCENDING);
}
try {
return getPossibleParents(offset,limit,orders);
} catch (Exception e) {
getApp().getLog().error(e);
return null;
}
},
(CallbackDataProvider.CountCallback<Account, Void>) query -> {
try {
return getPossibleParentsCount();
} catch (Exception e) {
getApp().getLog().error(e);
return 0;
}
});
return dataProvider;
}
代码示例来源:origin: jpos/jPOS-EE
@Override
public DataProvider getDataProvider() {
Map<String,Boolean> orders = new HashMap<>();
DataProvider dataProvider = DataProvider.fromCallbacks(
(CallbackDataProvider.FetchCallback) query -> {
int offset = query.getOffset();
int limit = query.getLimit();
for (Object o : query.getSortOrders()) {
QuerySortOrder order = (QuerySortOrder) o;
orders.put(order.getSorted(), order.getDirection() == SortDirection.DESCENDING);
}
DateRange dateRange = (DateRange) query.getFilter().orElse(null);
try {
return getAll(offset,limit,orders,defaultJournalId,dateRange);
} catch (Exception e) {
getApp().getLog().error(e);
return null;
}
},
(CallbackDataProvider.CountCallback) query -> {
DateRange dateRange = (DateRange) query.getFilter().orElse(null);
try {
return getItemCount(defaultJournalId,dateRange);
} catch (Exception e) {
getApp().getLog().error(e);
return 0;
}
});
return (ConfigurableFilterDataProvider<GLTransaction,Void,DateRange>) dataProvider.withConfigurableFilter();
}
代码示例来源:origin: jpos/jPOS-EE
@Override
public DataProvider getDataProvider() {
Map<String,Boolean> orders = new HashMap<>();
DataProvider dataProvider = DataProvider.fromCallbacks(
(CallbackDataProvider.FetchCallback) query -> {
int offset = query.getOffset();
int limit = query.getLimit();
for (Object o : query.getSortOrders()) {
QuerySortOrder order = (QuerySortOrder) o;
orders.put(order.getSorted(), order.getDirection() == SortDirection.DESCENDING);
}
User user = (User) query.getFilter().orElse(null);
try {
return getAll(offset,limit,orders,user);
} catch (Exception e) {
getApp().getLog().error(e);
return null;
}
},
(CallbackDataProvider.CountCallback) query -> {
User user = (User) query.getFilter().orElse(null);
try {
return getItemCount(user);
} catch (Exception e) {
getApp().getLog().error(e);
return 0;
}
});
return (ConfigurableFilterDataProvider<Consumer,Void,User>) dataProvider.withConfigurableFilter();
}
代码示例来源:origin: AxonIQ/giftcard-demo
new FetchCardSummariesQuery(query.getOffset(), query.getLimit(), filter);
log.trace("submitting {}", fetchCardSummariesQuery);
内容来源于网络,如有侵权,请联系作者删除!