use of com.linkedin.restli.server.CollectionResult in project rest.li by linkedin.
the class GreetingsResourceImpl method searchWithPostFilter.
@Finder("searchWithPostFilter")
public CollectionResult<Greeting, Empty> searchWithPostFilter(@PagingContextParam PagingContext ctx) {
List<Greeting> greetings = new ArrayList<Greeting>();
int idx = 0;
int start = ctx.getStart();
int stop = start + ctx.getCount();
for (Greeting g : _db.values()) {
if (idx++ >= ctx.getStart()) {
greetings.add(g);
if (idx == stop) {
break;
}
}
}
// for testing, using a post-filter that just removes the first element
if (greetings.size() > 0)
greetings.remove(0);
int total = _db.values().size();
// this is to keep paging consistent even in the presence of a post filter.
return new CollectionResult<Greeting, Empty>(greetings, total, null, PageIncrement.FIXED);
}
Aggregations