org.infinispan.api.common.query.QueryRequestBuilder Maven / Gradle / Ivy
package org.infinispan.api.common.query;
import java.util.HashMap;
import java.util.Map;
/**
* Builder class to build {@link QueryRequest}
*
* Different parameters can be specified:
*
* Ickle Query: Mandatory query string
* Param: Parameters for the query/li>
* Skip: Skip this number of entries
* Limit: Limit the result to this number of entries
*
*
* @since 14.0
*/
public final class QueryRequestBuilder {
private final Map params;
private String ickleQuery;
private long skip;
private int limit = -1;
private QueryRequestBuilder() {
params = new HashMap<>();
}
public static QueryRequestBuilder query(String ickleQuery) {
QueryRequestBuilder queryParameters = new QueryRequestBuilder();
queryParameters.ickleQuery = ickleQuery;
return queryParameters;
}
public QueryRequestBuilder param(String name, Object value) {
params.put(name, value);
return this;
}
public QueryRequestBuilder skip(long skip) {
this.skip = skip;
return this;
}
public QueryRequestBuilder limit(int limit) {
this.limit = limit;
return this;
}
public QueryRequest find() {
return new QueryRequest(ickleQuery, params, skip, limit);
}
}