本文整理汇总了Java中com.hazelcast.query.PagingPredicate.setPage方法的典型用法代码示例。如果您正苦于以下问题:Java PagingPredicate.setPage方法的具体用法?Java PagingPredicate.setPage怎么用?Java PagingPredicate.setPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.query.PagingPredicate
的用法示例。
在下文中一共展示了PagingPredicate.setPage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
import com.hazelcast.query.PagingPredicate; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
Deque<String> userIdDeque = exchange.getQueryParameters().get("userId");
String userId = userIdDeque == null? "%" : userIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
if(logger.isDebugEnabled()) logger.debug("userId = " + userId + " page = " + page + " pageSize = " + pageSize);
LikePredicate likePredicate = new LikePredicate("userId", userId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new RefreshTokenComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<RefreshToken> values = tokens.values(pagingPredicate);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例2: handleRequest
import com.hazelcast.query.PagingPredicate; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
Deque<String> userIdDeque = exchange.getQueryParameters().get("userId");
String userId = userIdDeque == null? "%" : userIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("userId", userId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new UserComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<User> values = users.values(pagingPredicate);
for (User value : values) {
value.setPassword(null);
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例3: handleRequest
import com.hazelcast.query.PagingPredicate; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");
Deque<String> serviceIdDeque = exchange.getQueryParameters().get("serviceId");
String serviceId = serviceIdDeque == null? "%" : serviceIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("serviceId", serviceId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ServiceComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Service> values = services.values(pagingPredicate);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例4: handleRequest
import com.hazelcast.query.PagingPredicate; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
Deque<String> clientNameDeque = exchange.getQueryParameters().get("clientName");
String clientName = clientNameDeque == null? "%" : clientNameDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("clientName", clientName);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ClientComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Client> values = clients.values(pagingPredicate);
List results = new ArrayList();
for (Client value : values) {
Client c = Client.copyClient(value);
c.setClientSecret(null);
results.add(c);
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(results));
}