com.github.alittlehuang.data.query.support.AbstractQueryStored Maven / Gradle / Ivy
The newest version!
package com.github.alittlehuang.data.query.support;
import com.github.alittlehuang.data.query.page.PageFactory;
import com.github.alittlehuang.data.query.specification.BaseQueryStored;
import com.github.alittlehuang.data.query.specification.Criteria;
/**
* @author ALittleHuang
*/
public abstract class AbstractQueryStored implements BaseQueryStored {
protected static final int DEFAULT_PAGE_SIZE = 10;
protected Criteria criteria;
protected Class type;
private final PageFactory pageFactory;
public AbstractQueryStored(PageFactory pageFactory) {
this.pageFactory = pageFactory;
}
void setCriteria(Criteria criteria) {
this.criteria = criteria;
}
protected Criteria getCriteria() {
return criteria;
}
@Override
public Class getJavaType() {
return type;
}
@Override
public P getPage() {
Criteria criteria = getCriteria();
Long offset = criteria.getOffset();
offset = offset == null ? 0 : offset;
Long maxResults = criteria.getMaxResults();
maxResults = maxResults == null ? DEFAULT_PAGE_SIZE : maxResults;
return getPage(( offset / maxResults ), maxResults);
}
protected PageFactory getPageFactory() {
return pageFactory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy