com.github.restup.query.AbstractResourceQueryStatement Maven / Gradle / Ivy
package com.github.restup.query;
import static com.github.restup.util.UpUtils.unmodifiableList;
import java.util.List;
import com.github.restup.query.criteria.ResourceQueryCriteria;
import com.github.restup.registry.Resource;
abstract class AbstractResourceQueryStatement {
final Resource, ?> resource;
// query criteria
private final List requestedCriteria;
// sorting
private final List requestedSort;
// pagination
private final Pagination pagination;
public AbstractResourceQueryStatement(Resource, ?> resource, List requestedCriteria,
List requestedSort, Pagination pagination) {
super();
this.resource = resource;
this.requestedCriteria = unmodifiableList(requestedCriteria);
this.requestedSort = unmodifiableList(requestedSort);
this.pagination = pagination;
}
public static boolean hasCriteria(AbstractResourceQueryStatement query) {
return query != null && query.getRequestedCriteria() != null;
}
public boolean isPagingEnabled() {
return pagination.isPagingEnabled();
}
public Resource, ?> getResource() {
return resource;
}
public List getRequestedCriteria() {
return requestedCriteria;
}
public List getRequestedSort() {
return requestedSort;
}
public Pagination getPagination() {
return pagination;
}
}