
org.beangle.commons.dao.query.builder.QueryBean Maven / Gradle / Ivy
The newest version!
/*
* Beangle, Agile Development Scaffold and Toolkits.
*
* Copyright © 2005, The Beangle Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
package org.beangle.commons.dao.query.builder;
import java.util.Map;
import org.beangle.commons.collection.page.PageLimit;
import org.beangle.commons.dao.query.Lang;
import org.beangle.commons.dao.query.LimitQuery;
import org.beangle.commons.dao.query.Query;
import org.beangle.commons.lang.Strings;
/**
*
* QueryBean class.
*
*
* @author chaostone
* @version $Id: $
*/
public class QueryBean implements LimitQuery {
private Lang lang;
private String statement;
private String countStatement;
private PageLimit limit;
private boolean cacheable;
private Map params;
/**
* Returns count query {@link org.beangle.commons.dao.query.Query}.
*/
public Query getCountQuery() {
if (Strings.isEmpty(countStatement)) { return null; }
QueryBean bean = new QueryBean();
bean.setStatement(countStatement);
bean.setLang(lang);
bean.setParams(params);
bean.setCacheable(cacheable);
return bean;
}
/**
* Returns statement.
*/
public String getStatement() {
return statement;
}
/**
*
* Getter for the field countStatement
.
*
*
* @return a {@link java.lang.String} object.
*/
public String getCountStatement() {
return countStatement;
}
/**
*
* Getter for the field limit
.
*
*
* @return a {@link org.beangle.commons.collection.page.PageLimit} object.
*/
public PageLimit getLimit() {
return limit;
}
/**
*
* Getter for the field params
.
*
*
* @return a {@link java.util.Map} object.
*/
public Map getParams() {
return params;
}
/**
*
* Setter for the field statement
.
*
*
* @param statement a {@link java.lang.String} object.
*/
public void setStatement(String statement) {
this.statement = statement;
}
/**
*
* Setter for the field countStatement
.
*
*
* @param countStatement a {@link java.lang.String} object.
*/
public void setCountStatement(String countStatement) {
this.countStatement = countStatement;
}
/**
*
* Setter for the field limit
.
*
*
* @param limit a {@link org.beangle.commons.collection.page.PageLimit} object.
*/
public void setLimit(PageLimit limit) {
this.limit = limit;
}
/** {@inheritDoc} */
public LimitQuery limit(PageLimit limit) {
this.limit = new PageLimit(limit.getPageIndex(), limit.getPageSize());
return this;
}
/**
*
* Setter for the field cacheable
.
*
*
* @param cacheable a boolean.
*/
public void setCacheable(boolean cacheable) {
this.cacheable = cacheable;
}
/**
*
* Setter for the field params
.
*
*
* @param params a {@link java.util.Map} object.
*/
public void setParams(Map params) {
this.params = params;
}
/**
*
* isCacheable.
*
*
* @return a boolean.
*/
public boolean isCacheable() {
return cacheable;
}
/**
*
* Getter for the field lang
.
*
*
* @return a {@link org.beangle.commons.dao.query.Lang} object.
*/
public Lang getLang() {
return lang;
}
/**
*
* Setter for the field lang
.
*
*
* @param lang a {@link org.beangle.commons.dao.query.Lang} object.
*/
public void setLang(Lang lang) {
this.lang = lang;
}
}